class ImageEffectAddForm
Same name and namespace in other branches
- 11.x core/modules/image/src/Form/ImageEffectAddForm.php \Drupal\image\Form\ImageEffectAddForm
- 10 core/modules/image/src/Form/ImageEffectAddForm.php \Drupal\image\Form\ImageEffectAddForm
- 8.9.x core/modules/image/src/Form/ImageEffectAddForm.php \Drupal\image\Form\ImageEffectAddForm
Provides an add form for image effects.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase extends \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\image\Form\ImageEffectFormBase implements \Drupal\Core\Form\FormBase
- class \Drupal\image\Form\ImageEffectAddForm implements \Drupal\image\Form\ImageEffectFormBase
- class \Drupal\image\Form\ImageEffectFormBase implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of ImageEffectAddForm
1 string reference to 'ImageEffectAddForm'
- image.routing.yml in core/
modules/ image/ image.routing.yml - core/modules/image/image.routing.yml
File
-
core/
modules/ image/ src/ Form/ ImageEffectAddForm.php, line 15
Namespace
Drupal\image\FormView source
class ImageEffectAddForm extends ImageEffectFormBase {
/**
* The image effect manager.
*
* @var \Drupal\image\ImageEffectManager
*/
protected $effectManager;
/**
* Constructs a new ImageEffectAddForm.
*
* @param \Drupal\image\ImageEffectManager $effect_manager
* The image effect manager.
*/
public function __construct(ImageEffectManager $effect_manager) {
$this->effectManager = $effect_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('plugin.manager.image.effect'));
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
protected function prepareImageEffect($image_effect) {
$image_effect = $this->effectManager
->createInstance($image_effect);
// Set the initial weight so this effect comes last.
$image_effect->setWeight(count($this->imageStyle
->getEffects()));
return $image_effect;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.