/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $configs = $options['configs']; $data = $form->getViewData(); if (!empty($data)) { if (!$data instanceof Image) { $data = new Image($form->getConfig()->getAttribute('rootDir') . '/' . $data); } if ($data->hasThumbnail($this->selected)) { $thumbnail = $data->getThumbnail($this->selected); $view->vars['thumbnail'] = array('file' => $configs['folder'] . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()); } $value = $configs['folder'] . '/' . $data->getFilename(); $view->vars = array_replace($view->vars, array('value' => $value, 'file' => $value, 'width' => $data->getWidth(), 'height' => $data->getHeight())); } $view->vars['filters'] = $this->filters; }
/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form) { $configs = $form->getAttribute('configs'); $data = $form->getClientData(); if (!empty($data)) { if (!$data instanceof Image) { $data = new Image($form->getAttribute('rootDir') . '/' . $data); } if ($data->hasThumbnail($this->selected)) { $thumbnail = $data->getTumbnail($this->selected); $view->set('thumbnail', array('file' => $configs['folder'] . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight())); } $value = $configs['folder'] . '/' . $data->getFilename(); $view->set('value', $value)->set('file', $value)->set('width', $data->getWidth())->set('height', $data->getHeight()); } $view->set('filters', $this->filters); }