Same filename and directory in other branches
- 8.9.x core/modules/image/src/Form/ImageEffectAddForm.php
- 9 core/modules/image/src/Form/ImageEffectAddForm.php
Namespace
Drupal\image\Form
File
core/modules/image/src/Form/ImageEffectAddForm.php
View source
<?php
namespace Drupal\image\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\image\ImageEffectManager;
use Drupal\image\ImageStyleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ImageEffectAddForm extends ImageEffectFormBase {
protected $effectManager;
public function __construct(ImageEffectManager $effect_manager) {
$this->effectManager = $effect_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.image.effect'));
}
public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) {
$form = parent::buildForm($form, $form_state, $image_style, $image_effect);
$form['#title'] = $this
->t('Add %label effect to style %style', [
'%label' => $this->imageEffect
->label(),
'%style' => $image_style
->label(),
]);
$form['actions']['submit']['#value'] = $this
->t('Add effect');
return $form;
}
protected function prepareImageEffect($image_effect) {
$image_effect = $this->effectManager
->createInstance($image_effect);
$image_effect
->setWeight(count($this->imageStyle
->getEffects()));
return $image_effect;
}
}
Classes