/** * @param $entity * @param $file */ private function mogrify($entity, $file) { $propertyName = $file['property']->name; $getter = 'get' . ucFirst($propertyName); if (method_exists($entity, $getter)) { /** @var $uploadedFile \Symfony\Component\HttpFoundation\File\UploadedFile */ $uploadedFile = $entity->{$getter}(); if (null !== $uploadedFile) { $this->imManager->mogrify($file['params'], $uploadedFile->getPathName()); } } }
/** * @param \Symfony\Component\Form\FormView $view * @param \Symfony\Component\Form\FormInterface $form * @param array $options */ public function buildView(FormView $view, FormInterface $form, array $options) { if (isset($view->vars['file_url']) && null !== $options['im_format']) { $view->vars['file_url'] = $this->imManager->getUrl($options['im_format'], $view->vars['file_url']); } }
/** * @param Manager $manager * * @depends test__construct */ public function testGetUrl(Manager $manager) { $format = 'someformat'; $path = 'somepath'; $this->assertEquals($this->cachePath . '/' . $format . '/' . $path, $manager->getUrl($format, $path)); $manager->setCachePath('somepath/'); $this->assertEquals('somepath/' . $format . '/' . $path, $manager->getUrl($format, $path)); $manager->setCachePath($this->cachePath); }