diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 7bec79b..dcb39c6 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -23,8 +23,6 @@ * @see hook_entity_info_alter() */ function entity_get_info($entity_type = NULL) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); - // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; if (!isset($drupal_static_fast)) { @@ -32,16 +30,17 @@ function entity_get_info($entity_type = NULL) { } $entity_info = &$drupal_static_fast['entity_info']; - // Drupal\Core\Plugin\Type\EntityManager includes translated strings, so each - // language is cached separately. - $langcode = $language_interface->langcode; - if (empty($entity_info)) { + // Entity type plugins includes translated strings, so each language is + // cached separately. + $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; if ($cache = cache()->get("entity_info:$langcode")) { $entity_info = $cache->data; } else { $entity_info = drupal_container()->get('plugin.manager.entity')->getDefinitions(); + // @todo Replace this with Drupal\Core\Plugin\Discovery\CacheDecorator + // once http://drupal.org/node/1722882 adds cache tag support. cache()->set("entity_info:$langcode", $entity_info, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); } } diff --git a/core/lib/Drupal/Core/Plugin/Type/EntityManager.php b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php index 2dd2ad7..95db1d1 100644 --- a/core/lib/Drupal/Core/Plugin/Type/EntityManager.php +++ b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php @@ -2,13 +2,12 @@ /** * @file - * Definition of Drupal\Core\Plugin\Type\EntityManager. + * Contains Drupal\Core\Plugin\Type\EntityManager. */ namespace Drupal\Core\Plugin\Type; use Drupal\Component\Plugin\PluginManagerBase; -use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\ModuleDecorator; @@ -109,7 +108,9 @@ class EntityManager extends PluginManagerBase { public function __construct() { - $this->discovery = new ModuleDecorator(new AlterDecorator(new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('Core', 'Entity')), 'entity_info')); + // @todo Wrap this with Drupal\Core\Plugin\Discovery\CacheDecorator + // once http://drupal.org/node/1722882 adds cache tag support. + $this->discovery = new ModuleDecorator(new AlterDecorator(new AnnotatedClassDiscovery('Core', 'Entity'), 'entity_info')); $this->factory = new DefaultFactory($this); $this->defaults = array( diff --git a/core/modules/image/image.api.php b/core/modules/image/image.api.php index 1879a07..c11347f 100644 --- a/core/modules/image/image.api.php +++ b/core/modules/image/image.api.php @@ -74,7 +74,7 @@ function hook_image_effect_info_alter(&$effects) { * be cleared using this hook. This hook is called whenever a style is updated, * deleted, or any effect associated with the style is update or deleted. * - * @param Drupal\image\ImageStyle $style + * @param Drupal\image\Plugin\Core\Entity\ImageStyle $style * The image style array that is being flushed. */ function hook_image_style_flush($style) { diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 4f273af..d0c2899 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -10,7 +10,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Drupal\Component\Uuid\Uuid; use Drupal\file\Plugin\Core\Entity\File; -use Drupal\image\ImageStyle; +use Drupal\image\Plugin\Core\Entity\ImageStyle; /** * Image style constant for user presets in the database. @@ -597,7 +597,7 @@ function image_image_style_update($style) { /** * Delete an image style. * - * @param Drupal\image\ImageStyle $style + * @param Drupal\image\Plugin\Core\Entity\ImageStyle $style * An image style array. * @param $replacement_style_name * (optional) When deleting a style, specify a replacement style name so @@ -1164,26 +1164,6 @@ function _image_effect_definitions_sort($a, $b) { } /** - * Implements hook_entity_info(). - */ -function image_entity_info() { - return array( - 'image_style' => array( - 'label' => t('Image style'), - 'entity class' => 'Drupal\image\ImageStyle', - 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', - 'uri callback' => 'image_style_uri', - 'config prefix' => 'image.style', - 'entity keys' => array( - 'id' => 'name', - 'label' => 'label', - 'uuid' => 'uuid', - ), - ), - ); -} - -/** * URI callbacks for image styles. */ function image_style_uri(ImageStyle $image_style) { diff --git a/core/modules/image/lib/Drupal/image/ImageStyle.php b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php similarity index 51% rename from core/modules/image/lib/Drupal/image/ImageStyle.php rename to core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php index fae896f..363fbd8 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php @@ -2,15 +2,31 @@ /** * @file - * Definition of Drupal\image\ImageStyle. + * Definition of Drupal\image\Plugin\Core\Entity\ImageStyle. */ -namespace Drupal\image; +namespace Drupal\image\Plugin\Core\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines an image style configuration entity. + * + * @Plugin( + * id = "image_style", + * label = @Translation("Image style"), + * module = "image", + * controller_class = "Drupal\Core\Config\Entity\ConfigStorageController", + * uri_callback = "image_style_uri", + * config_prefix = "image.style", + * entity_keys = { + * "id" = "name", + * "label" = "label", + * "uuid" = "uuid" + * } + * ) */ class ImageStyle extends ConfigEntityBase {