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();
        }
    }
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();
        }
    }
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 ( ) ; } }
Override an alternative if required

@param FormInterface $form
Override an alternative if required