original_string: protected function overrideAlternative(FormInterface $form)
      {
          $needFlush = false;
          foreach ($this->thumbnailConfig as $format => $parameters) {
              $file = $form->get('files')->get($format)->get('file')->getData();
              if (null !== $file) {
                  $media = $form->getData();
                  $tmpFileName = time() . '-' . $file->getClientOriginalName();
                  $file->move($this->tmpDir, $tmpFileName);
                  $tmpFilePath = $this->tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
                  $this->imageAlternativeStrategy->overrideAlternative($media, $tmpFilePath, $format);
                 $this->objectManager->persist($media);
                  $needFlush = true;
              }
          }
          if ($needFlush) {
              $this->objectManager->flush();
          }
      }
code: protected function overrideAlternative(FormInterface $form)
      {
          $needFlush = false;
          foreach ($this->thumbnailConfig as $format => $parameters) {
              $file = $form->get('files')->get($format)->get('file')->getData();
              if (null !== $file) {
                  $media = $form->getData();
                  $tmpFileName = time() . '-' . $file->getClientOriginalName();
                  $file->move($this->tmpDir, $tmpFileName);
                  $tmpFilePath = $this->tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
                  $this->imageAlternativeStrategy->overrideAlternative($media, $tmpFilePath, $format);
                 $this->objectManager->persist($media);
                  $needFlush = true;
              }
          }
          if ($needFlush) {
              $this->objectManager->flush();
          }
      }
code_tokens: protected function overrideAlternative ( FormInterface $ form ) { $ needFlush = false ; foreach ( $ this -> thumbnailConfig as $ format => $ parameters ) { $ file = $ form -> get ( 'files' ) -> get ( $ format ) -> get ( 'file' ) -> getData ( ) ; if ( null !== $ file ) { $ media = $ form -> getData ( ) ; $ tmpFileName = time ( ) . '-' . $ file -> getClientOriginalName ( ) ; $ file -> move ( $ this -> tmpDir , $ tmpFileName ) ; $ tmpFilePath = $ this -> tmpDir . DIRECTORY_SEPARATOR . $ tmpFileName ; $ this -> imageAlternativeStrategy -> overrideAlternative ( $ media , $ tmpFilePath , $ format ) ; $ this -> objectManager -> persist ( $ media ) ; $ needFlush = true ; } } if ( $ needFlush ) { $ this -> objectManager -> flush ( ) ; } }
docstring: Override an alternative if required
  
  @param FormInterface $form
docstring_tokens: Override an alternative if required