/** * @param \Symfony\Component\Form\FormView $view * @param \Symfony\Component\Form\FormInterface $form */ public function buildView(FormView $view, FormInterface $form) { $format = $form->getAttribute('format'); $imageSrc = $view->get('image_src'); if ($imageSrc !== null && $format !== null) { $view->set('image_src', $this->imManager->getUrl($format, $imageSrc)); } }
/** * @param $entity * @param $file */ private function mogrify($entity, $file) { $uploadedFile = $this->propertyAccessor->getValue($entity, $file->name); if ($uploadedFile instanceof UploadedFile) { $this->imManager->mogrify($file->params, $uploadedFile->getPathName()); } }
private function mogrify($entity, $file) { $propertyName = $file['property']->name; if (isset($entity->{$propertyName})) { /** @var $uploadedFile \Symfony\Component\HttpFoundation\File\UploadedFile */ $uploadedFile = $entity->{$propertyName}; 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(Manager::DEFAULT_IM_PATH . $format . '/' . $path, $manager->getUrl($format, $path)); $manager->setCachePath('somepath/'); $this->assertEquals('somepath/' . $format . '/' . $path, $manager->getUrl($format, $path)); $manager->setCachePath(Manager::DEFAULT_IM_PATH); }