Commit 76a157fe authored by webchick's avatar webchick

Issue #1763974 by tim.plunkett, EclipseGC, berdir, xjm, neclimdul, FabianX:...

Issue #1763974 by tim.plunkett, EclipseGC, berdir, xjm, neclimdul, FabianX: Convert entity type info into plugins.
parent a61f62b4
This diff is collapsed.
......@@ -10,18 +10,21 @@
use Drupal\Core\Entity\EntityInterface;
/**
* Gets the entity info array of an entity type.
* Gets the entity definition for an entity type.
*
* @param $entity_type
* The entity type, e.g. node, for which the info shall be returned, or NULL
* to return an array with info about all types.
* @param string|null $entity_type
* (optional) The entity type (e.g. 'node'). Leave NULL to retrieve
* information for all entity types.
*
* @return array
* An array containing the entity type's definition, as retrieved with
* \Drupal\Core\Entity\EntityManager. If $entity_type is NULL, an associative
* array of all entity type definitions keyed by entity type is returned.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
* @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)) {
......@@ -29,61 +32,8 @@ function entity_get_info($entity_type = NULL) {
}
$entity_info = &$drupal_static_fast['entity_info'];
// hook_entity_info() includes translated strings, so each language is cached
// separately.
$langcode = $language_interface->langcode;
if (empty($entity_info)) {
if ($cache = cache()->get("entity_info:$langcode")) {
$entity_info = $cache->data;
}
else {
$entity_info = module_invoke_all('entity_info');
// Merge in default values.
foreach ($entity_info as $name => $data) {
$entity_info[$name] += array(
'fieldable' => FALSE,
'entity class' => 'Drupal\Core\Entity\Entity',
'controller class' => 'Drupal\Core\Entity\DatabaseStorageController',
'list controller class' => 'Drupal\Core\Entity\EntityListController',
'render controller class' => 'Drupal\Core\Entity\EntityRenderController',
'form controller class' => array(
'default' => 'Drupal\Core\Entity\EntityFormController',
),
'static cache' => TRUE,
'field cache' => TRUE,
'bundles' => array(),
'view modes' => array(),
'entity keys' => array(),
'translation' => array(),
);
$entity_info[$name]['entity keys'] += array(
'revision' => '',
'bundle' => '',
);
foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) {
$entity_info[$name]['view modes'][$view_mode] += array(
'custom settings' => FALSE,
);
}
// If no bundle key is provided, assume a single bundle, named after
// the entity type.
if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
$entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
}
// Prepare entity schema fields SQL info for
// Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery().
if (isset($entity_info[$name]['base table'])) {
$entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']);
if (isset($entity_info[$name]['revision table'])) {
$entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']);
}
}
}
// Let other modules alter the entity info.
drupal_alter('entity_info', $entity_info);
cache()->set("entity_info:$langcode", $entity_info, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
}
$entity_info = drupal_container()->get('plugin.manager.entity')->getDefinitions();
}
if (empty($entity_type)) {
......@@ -116,7 +66,7 @@ function entity_info_cache_clear() {
* @return Drupal\Core\Entity\EntityInterface
* The entity object, or FALSE if there is no entity with the given id.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
* @see entity_load_multiple()
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
......@@ -139,7 +89,7 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* The entity object, or FALSE if there is no entity with the given revision
* id.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
*/
......@@ -177,14 +127,14 @@ function entity_revision_delete($entity_type, $revision_id) {
* @throws Drupal\Core\Entity\EntityStorageException
* Thrown in case the requested entity type does not support UUIDs.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
*/
function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
$entity_info = entity_get_info($entity_type);
if (empty($entity_info['entity keys']['uuid'])) {
if (empty($entity_info['entity_keys']['uuid'])) {
throw new EntityStorageException("Entity type $entity_type does not support UUIDs.");
}
$uuid_key = $entity_info['entity keys']['uuid'];
$uuid_key = $entity_info['entity_keys']['uuid'];
$controller = entity_get_controller($entity_type);
if ($reset) {
......@@ -205,11 +155,12 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
* Drupal\Core\Entity\EntityStorageControllerInterface interface. By default,
* Drupal\Core\Entity\DatabaseStorageController is used. Entity types can
* specify that a different class should be used by setting the
* 'controller class' key in hook_entity_info(). These classes can either
* implement the Drupal\Core\Entity\EntityStorageControllerInterface interface, or,
* most commonly, extend the Drupal\Core\Entity\DatabaseStorageController
* class. See node_entity_info() and the NodeStorageController in node.module as
* an example.
* 'controller_class' key in the entity plugin annotation. These classes can
* either implement the Drupal\Core\Entity\EntityStorageControllerInterface
* interface, or, most commonly, extend the
* Drupal\Core\Entity\DatabaseStorageController class.
* See Drupal\node\Plugin\Core\Entity\Node and Drupal\node\NodeStorageController
* for an example.
*
* @param string $entity_type
* The entity type to load, e.g. node or user.
......@@ -221,7 +172,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
* @return array
* An array of entity objects indexed by their ids.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
* @see Drupal\Core\Entity\Query\QueryInterface
......@@ -308,7 +259,7 @@ function entity_get_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
if (!isset($controllers[$entity_type])) {
$type_info = entity_get_info($entity_type);
$class = $type_info['controller class'];
$class = $type_info['controller_class'];
$controllers[$entity_type] = new $class($entity_type);
}
return $controllers[$entity_type];
......@@ -345,7 +296,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
* used. If a non-existing non-default operation is specified an exception will
* be thrown.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
*
* @param $entity_type
* The type of the entity.
......@@ -361,11 +312,11 @@ function entity_form_controller($entity_type, $operation = 'default') {
$info = entity_get_info($entity_type);
// Check whether there is a form controller class for the specified operation.
if (!empty($info['form controller class'][$operation])) {
$class = $info['form controller class'][$operation];
if (!empty($info['form_controller_class'][$operation])) {
$class = $info['form_controller_class'][$operation];
}
// If no controller is specified default to the base implementation.
elseif (empty($info['form controller class']) && $operation == 'default') {
elseif (empty($info['form_controller_class']) && $operation == 'default') {
$class = 'Drupal\Core\Entity\EntityFormController';
}
// If a non-existing operation has been specified stop.
......@@ -511,12 +462,12 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
* @return Drupal\Core\Entity\EntityListControllerInterface
* An entity list controller.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
*/
function entity_list_controller($entity_type) {
$storage = entity_get_controller($entity_type);
$entity_info = entity_get_info($entity_type);
$class = $entity_info['list controller class'];
$class = $entity_info['list_controller_class'];
return new $class($entity_type, $storage);
}
......@@ -529,11 +480,11 @@ function entity_list_controller($entity_type) {
* @return Drupal\Core\Entity\EntityRenderControllerInterface
* An entity render controller.
*
* @see hook_entity_info()
* @see \Drupal\Core\Entity\EntityManager
*/
function entity_render_controller($entity_type) {
$info = entity_get_info($entity_type);
$class = $info['render controller class'];
$class = $info['render_controller_class'];
return new $class($entity_type);
}
......
......@@ -65,7 +65,7 @@ public function __construct($entityType) {
$this->entityType = $entityType;
$this->entityInfo = entity_get_info($entityType);
$this->hookLoadArguments = array();
$this->idKey = $this->entityInfo['entity keys']['id'];
$this->idKey = $this->entityInfo['entity_keys']['id'];
}
/**
......@@ -158,8 +158,8 @@ public function loadByProperties(array $values = array()) {
* A SelectQuery object for loading the entity.
*/
protected function buildQuery($ids, $revision_id = FALSE) {
$config_class = $this->entityInfo['entity class'];
$prefix = $this->entityInfo['config prefix'] . '.';
$config_class = $this->entityInfo['class'];
$prefix = $this->entityInfo['config_prefix'] . '.';
// Load all of the configuration entities.
if ($ids === NULL) {
......@@ -220,7 +220,7 @@ protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
*/
public function create(array $values) {
$class = isset($this->entityInfo['entity class']) ? $this->entityInfo['entity class'] : 'Drupal\Core\Entity\Entity';
$class = $this->entityInfo['class'];
$entity = new $class($values, $this->entityType);
// Mark this entity as new, so isNew() returns TRUE. This does not check
......@@ -252,7 +252,7 @@ public function delete($ids) {
}
foreach ($entities as $id => $entity) {
$config = config($this->entityInfo['config prefix'] . '.' . $entity->id());
$config = config($this->entityInfo['config_prefix'] . '.' . $entity->id());
$config->delete();
}
......@@ -269,7 +269,7 @@ public function delete($ids) {
* When attempting to save a configuration entity that has no ID.
*/
public function save(EntityInterface $entity) {
$prefix = $this->entityInfo['config prefix'] . '.';
$prefix = $this->entityInfo['config_prefix'] . '.';
// Configuration entity IDs are strings, and '0' is a valid ID.
$id = $entity->id();
......
......@@ -70,6 +70,8 @@ public function build(ContainerBuilder $container) {
->addArgument(new Reference('router.dumper'))
->addArgument(new Reference('lock'));
$container->register('plugin.manager.entity', 'Drupal\Core\Entity\EntityManager');
$container->register('matcher', 'Drupal\Core\Routing\ChainMatcher');
$container->register('legacy_url_matcher', 'Drupal\Core\LegacyUrlMatcher')
->addTag('chained_matcher');
......
......@@ -117,27 +117,27 @@ public function __construct($entityType) {
$this->entityInfo = entity_get_info($entityType);
$this->entityCache = array();
$this->hookLoadArguments = array();
$this->idKey = $this->entityInfo['entity keys']['id'];
$this->idKey = $this->entityInfo['entity_keys']['id'];
// Check if the entity type supports UUIDs.
if (!empty($this->entityInfo['entity keys']['uuid'])) {
$this->uuidKey = $this->entityInfo['entity keys']['uuid'];
if (!empty($this->entityInfo['entity_keys']['uuid'])) {
$this->uuidKey = $this->entityInfo['entity_keys']['uuid'];
}
else {
$this->uuidKey = FALSE;
}
// Check if the entity type supports revisions.
if (!empty($this->entityInfo['entity keys']['revision'])) {
$this->revisionKey = $this->entityInfo['entity keys']['revision'];
$this->revisionTable = $this->entityInfo['revision table'];
if (!empty($this->entityInfo['entity_keys']['revision'])) {
$this->revisionKey = $this->entityInfo['entity_keys']['revision'];
$this->revisionTable = $this->entityInfo['revision_table'];
}
else {
$this->revisionKey = FALSE;
}
// Check if the entity type supports static caching of loaded entities.
$this->cache = !empty($this->entityInfo['static cache']);
$this->cache = !empty($this->entityInfo['static_cache']);
}
/**
......@@ -183,11 +183,11 @@ public function load(array $ids = NULL) {
// Build and execute the query.
$query_result = $this->buildQuery($ids)->execute();
if (!empty($this->entityInfo['entity class'])) {
if (!empty($this->entityInfo['class'])) {
// We provide the necessary arguments for PDO to create objects of the
// specified entity class.
// @see Drupal\Core\Entity\EntityInterface::__construct()
$query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType));
$query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['class'], array(array(), $this->entityType));
}
$queried_entities = $query_result->fetchAllAssoc($this->idKey);
}
......@@ -228,11 +228,11 @@ public function loadRevision($revision_id) {
// Build and execute the query.
$query_result = $this->buildQuery(array(), $revision_id)->execute();
if (!empty($this->entityInfo['entity class'])) {
if (!empty($this->entityInfo['class'])) {
// We provide the necessary arguments for PDO to create objects of the
// specified entity class.
// @see Drupal\Core\Entity\EntityInterface::__construct()
$query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType));
$query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['class'], array(array(), $this->entityType));
}
$queried_entities = $query_result->fetchAllAssoc($this->idKey);
......@@ -310,7 +310,7 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value
* A SelectQuery object for loading the entity.
*/
protected function buildQuery($ids, $revision_id = FALSE) {
$query = db_select($this->entityInfo['base table'], 'base');
$query = db_select($this->entityInfo['base_table'], 'base');
$query->addTag($this->entityType . '_load_multiple');
......@@ -322,11 +322,11 @@ protected function buildQuery($ids, $revision_id = FALSE) {
}
// Add fields from the {entity} table.
$entity_fields = $this->entityInfo['schema_fields_sql']['base table'];
$entity_fields = $this->entityInfo['schema_fields_sql']['base_table'];
if ($this->revisionKey) {
// Add all fields from the {entity_revision} table.
$entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision table']);
$entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision_table']);
// The id field is provided by entity, so remove it.
unset($entity_revision_fields[$this->idKey]);
......@@ -427,7 +427,7 @@ protected function cacheSet($entities) {
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
*/
public function create(array $values) {
$class = isset($this->entityInfo['entity class']) ? $this->entityInfo['entity class'] : 'Drupal\Core\Entity\Entity';
$class = $this->entityInfo['class'];
$entity = new $class($values, $this->entityType);
......@@ -458,7 +458,7 @@ public function delete($ids) {
}
$ids = array_keys($entities);
db_delete($this->entityInfo['base table'])
db_delete($this->entityInfo['base_table'])
->condition($this->idKey, $ids, 'IN')
->execute();
......@@ -501,7 +501,7 @@ public function save(EntityInterface $entity) {
if (!$entity->isNew()) {
if ($entity->isDefaultRevision()) {
$return = drupal_write_record($this->entityInfo['base table'], $entity, $this->idKey);
$return = drupal_write_record($this->entityInfo['base_table'], $entity, $this->idKey);
}
else {
// @todo, should a different value be returned when saving an entity
......@@ -516,7 +516,7 @@ public function save(EntityInterface $entity) {
$this->invokeHook('update', $entity);
}
else {
$return = drupal_write_record($this->entityInfo['base table'], $entity);
$return = drupal_write_record($this->entityInfo['base_table'], $entity);
if ($this->revisionKey) {
$this->saveRevision($entity);
}
......@@ -564,7 +564,7 @@ protected function saveRevision(EntityInterface $entity) {
if ($entity->isNewRevision()) {
drupal_write_record($this->revisionTable, $record);
if ($entity->isDefaultRevision()) {
db_update($this->entityInfo['base table'])
db_update($this->entityInfo['base_table'])
->fields(array($this->revisionKey => $record[$this->revisionKey]))
->condition($this->idKey, $entity->id())
->execute();
......
......@@ -41,14 +41,14 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
*/
public function __construct($entityType) {
parent::__construct($entityType);
$this->bundleKey = !empty($this->entityInfo['entity keys']['bundle']) ? $this->entityInfo['entity keys']['bundle'] : FALSE;
$this->entityClass = $this->entityInfo['entity class'];
$this->bundleKey = !empty($this->entityInfo['entity_keys']['bundle']) ? $this->entityInfo['entity_keys']['bundle'] : FALSE;
$this->entityClass = $this->entityInfo['class'];
// Work-a-round to let load() get stdClass storage records without having to
// override it. We map storage records to entities in
// DatabaseStorageControllerNG:: mapFromStorageRecords().
// @todo: Remove this once this is moved in the main controller.
unset($this->entityInfo['entity class']);
unset($this->entityInfo['class']);
}
/**
......@@ -181,13 +181,13 @@ public function save(EntityInterface $entity) {
$entity->updateOriginalValues();
if (!$entity->isNew()) {
$return = drupal_write_record($this->entityInfo['base table'], $record, $this->idKey);
$return = drupal_write_record($this->entityInfo['base_table'], $record, $this->idKey);
$this->resetCache(array($entity->id()));
$this->postSave($entity, TRUE);
$this->invokeHook('update', $entity);
}
else {
$return = drupal_write_record($this->entityInfo['base table'], $record);
$return = drupal_write_record($this->entityInfo['base_table'], $record);
// Reset general caches, but keep caches specific to certain entities.
$this->resetCache(array());
......@@ -234,7 +234,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
*/
protected function mapToStorageRecord(EntityInterface $entity) {
$record = new \stdClass();
foreach ($this->entityInfo['schema_fields_sql']['base table'] as $name) {
foreach ($this->entityInfo['schema_fields_sql']['base_table'] as $name) {
$record->$name = $entity->$name->value;
}
return $record;
......
......@@ -99,7 +99,7 @@ public function isNew() {
*/
public function isNewRevision() {
$info = $this->entityInfo();
return $this->newRevision || (!empty($info['entity keys']['revision']) && !$this->getRevisionId());
return $this->newRevision || (!empty($info['entity_keys']['revision']) && !$this->getRevisionId());
}
/**
......@@ -136,11 +136,11 @@ public function bundle() {
public function label($langcode = NULL) {
$label = NULL;
$entity_info = $this->entityInfo();
if (isset($entity_info['label callback']) && function_exists($entity_info['label callback'])) {
$label = $entity_info['label callback']($this->entityType, $this, $langcode);
if (isset($entity_info['label_callback']) && function_exists($entity_info['label_callback'])) {
$label = $entity_info['label_callback']($this->entityType, $this, $langcode);
}
elseif (!empty($entity_info['entity keys']['label']) && isset($this->{$entity_info['entity keys']['label']})) {
$label = $this->{$entity_info['entity keys']['label']};
elseif (!empty($entity_info['entity_keys']['label']) && isset($this->{$entity_info['entity_keys']['label']})) {
$label = $this->{$entity_info['entity_keys']['label']};
}
return $label;
}
......@@ -153,11 +153,11 @@ public function uri() {
// A bundle-specific callback takes precedence over the generic one for the
// entity type.
$entity_info = $this->entityInfo();
if (isset($entity_info['bundles'][$bundle]['uri callback'])) {
$uri_callback = $entity_info['bundles'][$bundle]['uri callback'];
if (isset($entity_info['bundles'][$bundle]['uri_callback'])) {
$uri_callback = $entity_info['bundles'][$bundle]['uri_callback'];
}
elseif (isset($entity_info['uri callback'])) {
$uri_callback = $entity_info['uri callback'];
elseif (isset($entity_info['uri_callback'])) {
$uri_callback = $entity_info['uri_callback'];
}
else {
return NULL;
......@@ -330,12 +330,12 @@ public function delete() {
public function createDuplicate() {
$duplicate = clone $this;
$entity_info = $this->entityInfo();
$duplicate->{$entity_info['entity keys']['id']} = NULL;
$duplicate->{$entity_info['entity_keys']['id']} = NULL;
// Check if the entity type supports UUIDs and generate a new one if so.
if (!empty($entity_info['entity keys']['uuid'])) {
if (!empty($entity_info['entity_keys']['uuid'])) {
$uuid = new Uuid();
$duplicate->{$entity_info['entity keys']['uuid']} = $uuid->generate();
$duplicate->{$entity_info['entity_keys']['uuid']} = $uuid->generate();
}
return $duplicate;
}
......
This diff is collapsed.
......@@ -398,12 +398,12 @@ public function __unset($name) {
public function createDuplicate() {
$duplicate = clone $this;
$entity_info = $this->entityInfo();
$duplicate->{$entity_info['entity keys']['id']}->value = NULL;
$duplicate->{$entity_info['entity_keys']['id']}->value = NULL;
// Check if the entity type supports UUIDs and generate a new one if so.
if (!empty($entity_info['entity keys']['uuid'])) {
if (!empty($entity_info['entity_keys']['uuid'])) {
$uuid = new Uuid();
$duplicate->{$entity_info['entity keys']['uuid']}->value = $uuid->generate();
$duplicate->{$entity_info['entity_keys']['uuid']}->value = $uuid->generate();
}
return $duplicate;
}
......
......@@ -10,9 +10,9 @@
/**
* Defines a common interface for entity controller classes.
*
* All entity controller classes specified via the 'controller class' key
* returned by hook_entity_info() or hook_entity_info_alter() have to implement
* this interface.
* All entity controller classes specified via the 'controller_class' key
* returned by \Drupal\Core\Entity\EntityManager or hook_entity_info_alter()
* have to implement this interface.
*
* Most simple, SQL-based entity controllers will do better by extending
* Drupal\Core\Entity\DatabaseStorageController instead of implementing this
......
......@@ -5,7 +5,7 @@
* Admin page callbacks for the book module.
*/
use Drupal\node\Node;
use Drupal\node\Plugin\Core\Entity\Node;
/**
* Page callback: Returns an administrative overview of all books.
......
......@@ -5,7 +5,7 @@
* Allows users to create and organize related content in an outline.
*/
use Drupal\node\Node;
use Drupal\node\Plugin\Core\Entity\Node;
use Drupal\Core\Template\Attribute;
/**
......@@ -253,11 +253,9 @@ function book_admin_paths() {
*/
function book_entity_info_alter(&$info) {
// Add the 'Print' view mode for nodes.
$info['node']['view modes'] += array(
'print' => array(
'label' => t('Print'),
'custom settings' => FALSE,
),
$info['node']['view_modes']['print'] = array(
'label' => t('Print'),
'custom_settings' => FALSE,
);
}
......
......@@ -5,7 +5,7 @@
* User page callbacks for the book module.
*/
use Drupal\node\Node;
use Drupal\node\Plugin\Core\Entity\Node;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......
......@@ -7,7 +7,7 @@
namespace Drupal\book\Tests;
use Drupal\node\Node;
use Drupal\node\Plugin\Core\Entity\Node;
use Drupal\simpletest\WebTestBase;
class BookTest extends WebTestBase {
......
......@@ -5,8 +5,8 @@
* Manage breakpoints and breakpoint groups for responsive designs.
*/
use Drupal\breakpoint\Breakpoint;
use Drupal\breakpoint\BreakpointGroup;
use Drupal\breakpoint\Plugin\Core\Entity\Breakpoint;
use Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroup;
/**
* Implements hook_help().
......@@ -193,7 +193,7 @@ function _breakpoint_delete_breakpoints($list, $source_type) {
// Remove the breakpoint.breakpoint part of the breakpoint identifier.
foreach ($ids as &$id) {
$id = drupal_substr($id, drupal_strlen($entity_info['config prefix']) + 1);
$id = drupal_substr($id, drupal_strlen($entity_info['config_prefix']) + 1);
}
$breakpoint_groups = entity_load_multiple('breakpoint_group', $ids);
......@@ -208,7 +208,7 @@ function _breakpoint_delete_breakpoints($list, $source_type) {
// Remove the breakpoint.breakpoint part of the breakpoint identifier.
foreach ($breakpoint_ids as &$breakpoint_id) {
$breakpoint_id = drupal_substr($breakpoint_id, drupal_strlen($entity_info['config prefix']) + 1);
$breakpoint_id = drupal_substr($breakpoint_id, drupal_strlen($entity_info['config_prefix']) + 1);
}
$breakpoints = entity_load_multiple('breakpoint', $breakpoint_ids);
......@@ -289,46 +289,13 @@ function breakpoint_get_module_media_queries($module) {
return array();
}
/**
* Implements hook_entity_info().
*/
function breakpoint_entity_info() {
// Breakpoint.
$types['breakpoint'] = array(
'label' => 'Breakpoint',
'entity class' => 'Drupal\breakpoint\Breakpoint',
'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController',
'config prefix' => 'breakpoint.breakpoint',
'entity keys' => array(
'id' => 'id',
'label' => 'label',
'uuid' => 'uuid',
),
);
// Breakpoint group.
$types['breakpoint_group'] = array(
'label' => 'Breakpoint group',
'entity class' => 'Drupal\breakpoint\BreakpointGroup',
'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController',
'config prefix' => 'breakpoint.breakpoint_group',
'entity keys' => array(
'id' => 'id',
'label' => 'label',
'uuid' => 'uuid',
),
);
return $types;
}
/**
* Load one breakpoint group by its identifier.
*
* @param string $id
* The id of the breakpoint group to load.
*
* @return Drupal\breakpoint\BreakpointGroup|false
* @return Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroup|false
* The breakpoint group, or FALSE if there is no entity with the given id.
*
* @todo Remove this in a follow-up issue.
......@@ -344,7 +311,7 @@ function breakpoint_group_load($id) {
* @param int $id
* The id of the breakpoint to load.
*
* @return Drupal\breakpoint\Breakpoint
* @return Drupal\breakpoint\Plugin\Core\Entity\Breakpoint