original_string: protected function cropAlternative(FormInterface $form)
      {
          $needFlush = false;
          foreach ($this->thumbnailConfig as $format => $parameters) {
              $x = $form->get('coordinates')->get($format)->get('x')->getData();
              $y = $form->get('coordinates')->get($format)->get('y')->getData();
              $h = $form->get('coordinates')->get($format)->get('h')->getData();
              $w = $form->get('coordinates')->get($format)->get('w')->getData();
              if (null !== $x && null !== $y && null !== $h && null !== $w) {
                  $media = $form->getData();
                  $this->imageAlternativeStrategy->cropAlternative($media, $x, $y, $h, $w, $format);
                  $this->objectManager->persist($media);
                  $needFlush = true;
              }
          }
          if ($needFlush) {
              $this->objectManager->flush();
          }
      }
code: protected function cropAlternative(FormInterface $form)
      {
          $needFlush = false;
          foreach ($this->thumbnailConfig as $format => $parameters) {
              $x = $form->get('coordinates')->get($format)->get('x')->getData();
              $y = $form->get('coordinates')->get($format)->get('y')->getData();
              $h = $form->get('coordinates')->get($format)->get('h')->getData();
              $w = $form->get('coordinates')->get($format)->get('w')->getData();
              if (null !== $x && null !== $y && null !== $h && null !== $w) {
                  $media = $form->getData();
                  $this->imageAlternativeStrategy->cropAlternative($media, $x, $y, $h, $w, $format);
                  $this->objectManager->persist($media);
                  $needFlush = true;
              }
          }
          if ($needFlush) {
              $this->objectManager->flush();
          }
      }
code_tokens: protected function cropAlternative ( FormInterface $ form ) { $ needFlush = false ; foreach ( $ this -> thumbnailConfig as $ format => $ parameters ) { $ x = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'x' ) -> getData ( ) ; $ y = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'y' ) -> getData ( ) ; $ h = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'h' ) -> getData ( ) ; $ w = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'w' ) -> getData ( ) ; if ( null !== $ x && null !== $ y && null !== $ h && null !== $ w ) { $ media = $ form -> getData ( ) ; $ this -> imageAlternativeStrategy -> cropAlternative ( $ media , $ x , $ y , $ h , $ w , $ format ) ; $ this -> objectManager -> persist ( $ media ) ; $ needFlush = true ; } } if ( $ needFlush ) { $ this -> objectManager -> flush ( ) ; } }
docstring: Crop a new Alternative if required
  
  @param FormInterface $form
docstring_tokens: Crop a new Alternative if required