diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 5111177..40beeb7 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\String; +use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageStyleInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -86,7 +87,8 @@ function image_style_form($form, &$form_state, ImageStyleInterface $style) { ); $links = array(); - if ($effect->hasForm()) { + $is_configurable = $effect instanceof ConfigurableImageEffectInterface; + if ($is_configurable) { $links['edit'] = array( 'title' => t('edit'), 'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key, @@ -104,7 +106,7 @@ function image_style_form($form, &$form_state, ImageStyleInterface $style) { '#type' => 'link', '#title' => t('edit'), '#href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key, - '#access' => $effect->hasForm(), + '#access' => $is_configurable, ); $form['effects'][$key]['remove'] = array( '#type' => 'link', @@ -174,7 +176,7 @@ function image_style_form_add_submit($form, &$form_state) { $effect = Drupal::service('plugin.manager.image.effect')->getDefinition($form_state['values']['new']); // Load the configuration form for this option. - if (!$effect['no_form']) { + if (!is_subclass_of($effect['class'], '\Drupal\image\ConfigurableImageEffectInterface')) { $path = 'admin/config/media/image-styles/manage/' . $style->id() . '/add/' . $form_state['values']['new']; $form_state['redirect'] = array($path, array('query' => array('weight' => $form_state['values']['weight']))); } diff --git a/core/modules/image/image.module b/core/modules/image/image.module index ef5ffbe..6293033 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -71,10 +71,10 @@ function image_help($path, $arg) { return '
' . t('Image styles commonly provide thumbnail sizes by scaling and cropping images, but can also add various effects before an image is displayed. When an image is displayed with a style, a new file is created and the original image is left unchanged.') . '
'; case 'admin/config/media/image-styles/manage/%/add/%': $effect = Drupal::service('plugin.manager.image.effect')->getDefinition($arg[7]); - return isset($effect['help']) ? ('' . $effect['help'] . '
') : NULL; + return isset($effect['description']) ? ('' . $effect['description'] . '
') : NULL; case 'admin/config/media/image-styles/manage/%/effects/%': $effect = entity_load('image_style', $arg[5])->getEffect($arg[7])->getPluginDefinition(); - return isset($effect['help']) ? ('' . $effect['help'] . '
') : NULL; + return isset($effect['description']) ? ('' . $effect['description'] . '
') : NULL; } } diff --git a/core/modules/image/lib/Drupal/image/Annotation/ImageEffect.php b/core/modules/image/lib/Drupal/image/Annotation/ImageEffect.php index efe1358..3a6f763 100644 --- a/core/modules/image/lib/Drupal/image/Annotation/ImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Annotation/ImageEffect.php @@ -26,7 +26,7 @@ class ImageEffect extends Plugin { public $id; /** - * The human-readable name of the type. + * The human-readable name of the image effect. * * @ingroup plugin_translatable * @@ -35,19 +35,14 @@ class ImageEffect extends Plugin { public $label; /** - * The human-readable name of the type. + * A brief description of the image effect. + * + * This will be shown when adding or configuring this image effect. * * @ingroup plugin_translatable * - * @var \Drupal\Core\Annotation\Translation + * @var \Drupal\Core\Annotation\Translation (optional) */ - public $help = ''; - - /** - * Determines if this image effect provides a form. - * - * @var bool - */ - public $no_form = FALSE; + public $description = ''; } diff --git a/core/modules/image/lib/Drupal/image/ConfigurableImageEffectInterface.php b/core/modules/image/lib/Drupal/image/ConfigurableImageEffectInterface.php new file mode 100644 index 0000000..292aa4c --- /dev/null +++ b/core/modules/image/lib/Drupal/image/ConfigurableImageEffectInterface.php @@ -0,0 +1,26 @@ +imageStyle = $image_style; $this->imageEffect = $this->prepareImageEffect($image_effect); - if (!$this->imageEffect->hasForm()) { + if (!($this->imageEffect instanceof ConfigurableImageEffectInterface)) { throw new NotFoundHttpException(); } @@ -78,7 +79,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU // Check the URL for a weight, then the image effect, otherwise use default. $form['weight'] = array( '#type' => 'hidden', - '#value' => $request->query->has('weight') ? intval($request->query->get('weight')) : $this->imageEffect->getWeight(), + '#value' => $request->query->has('weight') ? (int) $request->query->get('weight') : $this->imageEffect->getWeight(), ); $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/image/lib/Drupal/image/ImageEffectBase.php b/core/modules/image/lib/Drupal/image/ImageEffectBase.php index 9149a6d..a4ddeb5 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectBase.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectBase.php @@ -56,20 +56,6 @@ public function getSummary() { /** * {@inheritdoc} */ - public function getForm() { - return array(); - } - - /** - * {@inheritdoc} - */ - public function hasForm() { - return !$this->pluginDefinition['no_form']; - } - - /** - * {@inheritdoc} - */ public function label() { return $this->pluginDefinition['label']; } diff --git a/core/modules/image/lib/Drupal/image/ImageEffectInterface.php b/core/modules/image/lib/Drupal/image/ImageEffectInterface.php index ed0206e..05d5efd 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectInterface.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\image\Annotation\ImageEffectInterface. + * Contains \Drupal\image\ImageEffectInterface. */ namespace Drupal\image; @@ -43,25 +43,6 @@ public function transformDimensions(array &$dimensions); public function getSummary(); /** - * Builds the part of the image effect form specific to this image effect. - * - * This method is only responsible for the form elements specific to this - * image effect. All other aspects of the form are handled by calling code. - * - * @return array - * A render array. - */ - public function getForm(); - - /** - * Determines if a form should be provided to configure this image effect. - * - * @return bool - * TRUE if this image effect provides a form, FALSE otherwise. - */ - public function hasForm(); - - /** * Returns the image effect label. * * @return string diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php index afc7686..11f228e 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php @@ -16,7 +16,7 @@ * @ImageEffect( * id = "image_crop", * label = @Translation("Crop"), - * help = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.") + * description = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.") * ) */ class CropImageEffect extends ResizeImageEffect { diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php index b2b0f6e..816ed3e 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/DesaturateImageEffect.php @@ -17,8 +17,7 @@ * @ImageEffect( * id = "image_desaturate", * label = @Translation("Desaturate"), - * help = @Translation("Desaturate converts an image to grayscale."), - * no_form = TRUE + * description = @Translation("Desaturate converts an image to grayscale.") * ) */ class DesaturateImageEffect extends ImageEffectBase { diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php index 49e33d4..74239d9 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ResizeImageEffect.php @@ -9,6 +9,7 @@ use Drupal\Core\Annotation\Translation; use Drupal\image\Annotation\ImageEffect; +use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageEffectBase; /** @@ -17,10 +18,10 @@ * @ImageEffect( * id = "image_resize", * label = @Translation("Resize"), - * help = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.") + * description = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.") * ) */ -class ResizeImageEffect extends ImageEffectBase { +class ResizeImageEffect extends ImageEffectBase implements ConfigurableImageEffectInterface { /** * {@inheritdoc} diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php index dc2e305..dee537e 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/RotateImageEffect.php @@ -9,6 +9,7 @@ use Drupal\Core\Annotation\Translation; use Drupal\image\Annotation\ImageEffect; +use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageEffectBase; /** @@ -17,10 +18,10 @@ * @ImageEffect( * id = "image_rotate", * label = @Translation("Rotate"), - * help = @Translation("Rotating an image may cause the dimensions of an image to increase to fit the diagonal.") + * description = @Translation("Rotating an image may cause the dimensions of an image to increase to fit the diagonal.") * ) */ -class RotateImageEffect extends ImageEffectBase { +class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffectInterface { /** * {@inheritdoc} diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php index d5cedd1..dfa5955 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleAndCropImageEffect.php @@ -16,7 +16,7 @@ * @ImageEffect( * id = "image_scale_and_crop", * label = @Translation("Scale and crop"), - * help = @Translation("Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.") + * description = @Translation("Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.") * ) */ class ScaleAndCropImageEffect extends ResizeImageEffect { diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php index eb4817c..47ada5a 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/ScaleImageEffect.php @@ -17,7 +17,7 @@ * @ImageEffect( * id = "image_scale", * label = @Translation("Scale"), - * help = @Translation("Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.") + * description = @Translation("Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.") * ) */ class ScaleImageEffect extends ResizeImageEffect { diff --git a/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php b/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php index ca7c64b..23b1931 100644 --- a/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php +++ b/core/modules/image/tests/modules/image_module_test/lib/Drupal/image_module_test/Plugin/ImageEffect/NullTestImageEffect.php @@ -16,8 +16,7 @@ * * @ImageEffect( * id = "image_module_test_null", - * label = @Translation("Image module test"), - * no_form = TRUE + * label = @Translation("Image module test") * ) */ class NullTestImageEffect extends ImageEffectBase {