comparison core/modules/image/src/Entity/ImageStyle.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children 12f9dff5fda9
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
2 2
3 namespace Drupal\image\Entity; 3 namespace Drupal\image\Entity;
4 4
5 use Drupal\Core\Cache\Cache; 5 use Drupal\Core\Cache\Cache;
6 use Drupal\Core\Config\Entity\ConfigEntityBase; 6 use Drupal\Core\Config\Entity\ConfigEntityBase;
7 use Drupal\Core\Entity\Entity\EntityFormDisplay;
7 use Drupal\Core\Entity\EntityStorageInterface; 8 use Drupal\Core\Entity\EntityStorageInterface;
8 use Drupal\Core\Entity\EntityWithPluginCollectionInterface; 9 use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
9 use Drupal\Core\Routing\RequestHelper; 10 use Drupal\Core\Routing\RequestHelper;
10 use Drupal\Core\Site\Settings; 11 use Drupal\Core\Site\Settings;
11 use Drupal\Core\Url; 12 use Drupal\Core\Url;
12 use Drupal\image\ImageEffectPluginCollection; 13 use Drupal\image\ImageEffectPluginCollection;
13 use Drupal\image\ImageEffectInterface; 14 use Drupal\image\ImageEffectInterface;
14 use Drupal\image\ImageStyleInterface; 15 use Drupal\image\ImageStyleInterface;
15 use Drupal\Component\Utility\Crypt; 16 use Drupal\Component\Utility\Crypt;
16 use Drupal\Component\Utility\UrlHelper; 17 use Drupal\Component\Utility\UrlHelper;
17 use Drupal\Component\Utility\Unicode;
18 use Drupal\Core\StreamWrapper\StreamWrapperInterface; 18 use Drupal\Core\StreamWrapper\StreamWrapperInterface;
19 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; 19 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
20 use Drupal\Core\Entity\Entity\EntityViewDisplay; 20 use Drupal\Core\Entity\Entity\EntityViewDisplay;
21 21
22 /** 22 /**
23 * Defines an image style configuration entity. 23 * Defines an image style configuration entity.
24 * 24 *
25 * @ConfigEntityType( 25 * @ConfigEntityType(
26 * id = "image_style", 26 * id = "image_style",
27 * label = @Translation("Image style"), 27 * label = @Translation("Image style"),
28 * label_collection = @Translation("Image styles"),
29 * label_singular = @Translation("image style"),
30 * label_plural = @Translation("image styles"),
31 * label_count = @PluralTranslation(
32 * singular = "@count image style",
33 * plural = "@count image styles",
34 * ),
28 * handlers = { 35 * handlers = {
29 * "form" = { 36 * "form" = {
30 * "add" = "Drupal\image\Form\ImageStyleAddForm", 37 * "add" = "Drupal\image\Form\ImageStyleAddForm",
31 * "edit" = "Drupal\image\Form\ImageStyleEditForm", 38 * "edit" = "Drupal\image\Form\ImageStyleEditForm",
32 * "delete" = "Drupal\image\Form\ImageStyleDeleteForm", 39 * "delete" = "Drupal\image\Form\ImageStyleDeleteForm",
146 $display->setComponent($name, $options) 153 $display->setComponent($name, $options)
147 ->save(); 154 ->save();
148 } 155 }
149 } 156 }
150 } 157 }
151 foreach (EntityViewDisplay::loadMultiple() as $display) { 158 foreach (EntityFormDisplay::loadMultiple() as $display) {
152 foreach ($display->getComponents() as $name => $options) { 159 foreach ($display->getComponents() as $name => $options) {
153 if (isset($options['type']) && $options['type'] == 'image_image' && $options['settings']['preview_image_style'] == $style->getOriginalId()) { 160 if (isset($options['type']) && $options['type'] == 'image_image' && $options['settings']['preview_image_style'] == $style->getOriginalId()) {
154 $options['settings']['preview_image_style'] = $style->id(); 161 $options['settings']['preview_image_style'] = $style->id();
155 $display->setComponent($name, $options) 162 $display->setComponent($name, $options)
156 ->save(); 163 ->save();
346 */ 353 */
347 public function supportsUri($uri) { 354 public function supportsUri($uri) {
348 // Only support the URI if its extension is supported by the current image 355 // Only support the URI if its extension is supported by the current image
349 // toolkit. 356 // toolkit.
350 return in_array( 357 return in_array(
351 Unicode::strtolower(pathinfo($uri, PATHINFO_EXTENSION)), 358 mb_strtolower(pathinfo($uri, PATHINFO_EXTENSION)),
352 $this->getImageFactory()->getSupportedExtensions() 359 $this->getImageFactory()->getSupportedExtensions()
353 ); 360 );
354 } 361 }
355 362
356 /** 363 /**