Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('type' => 'silvestra_media_image', 'allow_add' => true, 'allow_delete' => true, 'label' => false, 'limit' => null, 'mime_types' => $this->defaultConfig->getAvailableMimeTypes(), 'max_file_size' => $this->defaultConfig->getMaxFileSize(), 'max_height' => $this->defaultConfig->getMaxHeight(), 'max_width' => $this->defaultConfig->getMaxWidth(), 'min_height' => $this->defaultConfig->getMinHeight(), 'min_width' => $this->defaultConfig->getMinWidth(), 'resize_strategy' => $this->defaultConfig->getDefaultResizeStrategy(), 'cropper_enabled' => $this->defaultConfig->isDefaultCropperEnabled(), 'cropper_coordinates' => function (Options $options) {
         return array('x1' => 0, 'y1' => 0, 'x2' => $options['max_width'], 'y2' => $options['max_height']);
     }, 'options' => function (Options $options) {
         array('mime_types' => $options['mime_types'], 'max_file_size' => $options['max_file_size'], 'max_height' => $options['max_height'], 'max_width' => $options['max_width'], 'min_height' => $options['min_height'], 'min_width' => $options['min_width'], 'resize_strategy' => $options['resize_strategy'], 'cropper_enabled' => $options['cropper_enabled'], 'cropper_coordinates' => $options['cropper_coordinates']);
     }));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => $this->imageClass, 'label' => false, 'mime_types' => $this->defaultConfig->getAvailableMimeTypes(), 'max_file_size' => $this->defaultConfig->getMaxFileSize(), 'max_height' => $this->defaultConfig->getMaxHeight(), 'max_width' => $this->defaultConfig->getMaxWidth(), 'min_height' => $this->defaultConfig->getMinHeight(), 'min_width' => $this->defaultConfig->getMinWidth(), 'resize_strategy' => $this->defaultConfig->getDefaultResizeStrategy(), 'cropper_enabled' => $this->defaultConfig->isDefaultCropperEnabled(), 'cropper_coordinates' => function (Options $options) {
         return array('x1' => 0, 'y1' => 0, 'x2' => $options['max_width'], 'y2' => $options['max_height']);
     }, 'error_bubbling' => false));
     $defaultConfig = $this->defaultConfig;
     $resolver->setAllowedValues(array('mime_types' => function ($mimeTypes) use($defaultConfig) {
         foreach ($mimeTypes as $type) {
             if (!in_array($type, $defaultConfig->getAvailableMimeTypes())) {
                 return false;
             }
         }
         return true;
     }, 'max_file_size' => function ($maxFileSize) use($defaultConfig) {
         return $defaultConfig->getMaxFileSize() >= $maxFileSize;
     }, 'max_height' => function ($maxHeight) use($defaultConfig) {
         return $defaultConfig->getMaxHeight() >= $maxHeight;
     }, 'max_width' => function ($maxWidth) use($defaultConfig) {
         return $defaultConfig->getMaxWidth() >= $maxWidth;
     }, 'min_height' => function ($minHeight) use($defaultConfig) {
         return $defaultConfig->getMinHeight() <= $minHeight;
     }, 'min_width' => function ($minWidth) use($defaultConfig) {
         return $defaultConfig->getMinWidth() <= $minWidth;
     }, 'resize_strategy' => function ($resizeStrategy) {
         return in_array($resizeStrategy, Media::getResizeStrategies());
     }));
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function validate($value, ImageDefaultConfig $defaultConfig)
 {
     return $defaultConfig->getMinHeight() <= $value;
 }