From 3a0569596fd426fa7c4b6eeddf858452fcb9ba2c Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 6 Jan 2014 12:29:43 +0000 Subject: [PATCH] Issue #2030643 by tarekdj, InternetDevels: Expand ImageStyle with methods. --- .../lib/Drupal/image/Entity/ImageStyle.php | 25 +++++++++++++++-- .../lib/Drupal/image/ImageStyleInterface.php | 28 +++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index aee3ffcdfca..57869d485f7 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -127,9 +127,9 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface { // Check whether field instance settings need to be updated. // In case no replacement style was specified, all image fields that are // using the deleted style are left in a broken state. - if ($new_id = $style->get('replacementID')) { + if ($new_id = $style->getReplacementID()) { // The deleted ID is still set as originalID. - $style->set('name', $new_id); + $style->setName($new_id); static::replaceImageStyle($style); } } @@ -372,4 +372,25 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface { return $properties; } + /** + * {@inheritdoc} + */ + public function getReplacementID() { + return $this->get('replacementID'); + } + + /** + * {@inheritdoc} + */ + public function getName() { + return $this->get('name'); + } + + /** + * {@inheritdoc} + */ + public function setName($name) { + $this->set('name', $name); + return $this; + } } diff --git a/core/modules/image/lib/Drupal/image/ImageStyleInterface.php b/core/modules/image/lib/Drupal/image/ImageStyleInterface.php index 3783fc49010..27e1e026535 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyleInterface.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleInterface.php @@ -15,6 +15,34 @@ use Drupal\image\ImageEffectInterface; */ interface ImageStyleInterface extends ConfigEntityInterface { + /** + * Returns the replacement ID. + * + * @return string + * The name of the image style to use as replacement upon delete. + */ + public function getReplacementID(); + + /** + * Returns the image style. + * + * @return string + * The name of the image style. + */ + public function getName(); + + /** + * Sets the name of the image style. + * + * @param string $name + * The name of the image style. + * + * @return \Drupal\image\ImageEffectInterface + * The class instance this method is called on. + */ + public function setName($name); + + /** * Returns the URI of this image when using this style. *