Commit bc237f9a authored by webchick's avatar webchick

Issue #1831264 by tim.plunkett: Use the Entity manager to create new controller instances.

parent 948728c5
......@@ -253,6 +253,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou
// higher-level configuration data.
// First pass deleted, then new, and lastly changed configuration, in order to
// handle dependencies correctly.
$manager = drupal_container()->get('plugin.manager.entity');
foreach (array('delete', 'create', 'change') as $op) {
foreach ($config_changes[$op] as $key => $name) {
// Call to the configuration entity's storage controller to handle the
......@@ -271,7 +272,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou
}
$method = 'import' . ucfirst($op);
$handled_by_module = entity_get_controller($entity_type)->$method($name, $new_config, $old_config);
$handled_by_module = $manager->getStorageController($entity_type)->$method($name, $new_config, $old_config);
}
if (!empty($handled_by_module)) {
unset($config_changes[$op][$key]);
......
......@@ -109,7 +109,9 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* @see Drupal\Core\Entity\DatabaseStorageController
*/
function entity_revision_load($entity_type, $revision_id) {
return entity_get_controller($entity_type)->loadRevision($revision_id);
return drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type)
->loadRevision($revision_id);
}
/**
......@@ -121,7 +123,9 @@ function entity_revision_load($entity_type, $revision_id) {
* The revision ID to delete.
*/
function entity_revision_delete($entity_type, $revision_id) {
entity_get_controller($entity_type)->deleteRevision($revision_id);
drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type)
->deleteRevision($revision_id);
}
/**
......@@ -151,7 +155,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
}
$uuid_key = $entity_info['entity_keys']['uuid'];
$controller = entity_get_controller($entity_type);
$controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type);
if ($reset) {
$controller->resetCache();
}
......@@ -193,10 +197,11 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
* @see Drupal\Core\Entity\Query\QueryInterface
*/
function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
$controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type);
if ($reset) {
entity_get_controller($entity_type)->resetCache();
$controller->resetCache();
}
return entity_get_controller($entity_type)->load($ids);
return $controller->load($ids);
}
/**
......@@ -212,7 +217,9 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
* An array of entity objects indexed by their ids.
*/
function entity_load_multiple_by_properties($entity_type, array $values) {
return entity_get_controller($entity_type)->loadByProperties($values);
return drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type)
->loadByProperties($values);
}
/**
......@@ -232,8 +239,9 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
* The unchanged entity, or FALSE if the entity cannot be loaded.
*/
function entity_load_unchanged($entity_type, $id) {
entity_get_controller($entity_type)->resetCache(array($id));
$result = entity_get_controller($entity_type)->load(array($id));
$controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type);
$controller->resetCache(array($id));
$result = $controller->load(array($id));
return reset($result);
}
......@@ -246,7 +254,7 @@ function entity_load_unchanged($entity_type, $id) {
* An array of entity IDs of the entities to delete.
*/
function entity_delete_multiple($entity_type, array $ids) {
$controller = entity_get_controller($entity_type);
$controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type);
$entities = $controller->load($ids);
$controller->delete($entities);
}
......@@ -264,22 +272,21 @@ function entity_delete_multiple($entity_type, array $ids) {
* A new entity object.
*/
function entity_create($entity_type, array $values) {
return entity_get_controller($entity_type)->create($values);
return drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type)
->create($values);
}
/**
* Gets the entity controller class for an entity type.
*
* @return Drupal\Core\Entity\EntityStorageControllerInterface
*
* @deprecated Use \Drupal\Core\Entity\EntityManager::getStorageController().
*/
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'];
$controllers[$entity_type] = new $class($entity_type);
}
return $controllers[$entity_type];
return drupal_container()->get('plugin.manager.entity')
->getStorageController($entity_type);
}
/**
......@@ -313,16 +320,11 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
* @return \Drupal\Core\Entity\EntityAccessControllerInterface
* An entity access controller instance.
*
* @see \Drupal\Core\Entity\EntityManager
* @deprecated Use \Drupal\Core\Entity\EntityManager::getRenderController().
*/
function entity_access_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
if (!isset($controllers[$entity_type])) {
$type_info = entity_get_info($entity_type);
$class = $type_info['access_controller_class'];
$controllers[$entity_type] = new $class($entity_type);
}
return $controllers[$entity_type];
return drupal_container()->get('plugin.manager.entity')
->getAccessController($entity_type);
}
/**
......@@ -345,24 +347,12 @@ function entity_access_controller($entity_type) {
*
* @return Drupal\Core\Entity\EntityFormControllerInterface
* An entity form controller instance.
*
* @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController().
*/
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 no controller is specified default to the base implementation.
elseif (empty($info['form_controller_class']) && $operation == 'default') {
$class = 'Drupal\Core\Entity\EntityFormController';
}
// If a non-existing operation has been specified stop.
else {
throw new InvalidArgumentException("Missing form controller for '$entity_type', operation '$operation'");
}
return new $class($operation);
return drupal_container()->get('plugin.manager.entity')
->getFormController($entity_type, $operation);
}
/**
......@@ -402,7 +392,7 @@ function entity_form_id(EntityInterface $entity, $operation = 'default') {
*/
function entity_form_state_defaults(EntityInterface $entity, $operation = 'default', $langcode = NULL) {
$form_state = array();
$controller = entity_form_controller($entity->entityType(), $operation);
$controller = drupal_container()->get('plugin.manager.entity')->getFormController($entity->entityType(), $operation);
$form_state['build_info']['callback'] = array($controller, 'build');
$form_state['build_info']['base_form_id'] = $entity->entityType() . '_form';
$form_state['build_info']['args'] = array($entity);
......@@ -500,13 +490,11 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
* @return Drupal\Core\Entity\EntityListControllerInterface
* An entity list controller.
*
* @see \Drupal\Core\Entity\EntityManager
* @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController().
*/
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'];
return new $class($entity_type, $storage);
return drupal_container()->get('plugin.manager.entity')
->getListController($entity_type);
}
/**
......@@ -518,12 +506,11 @@ function entity_list_controller($entity_type) {
* @return Drupal\Core\Entity\EntityRenderControllerInterface
* An entity render controller.
*
* @see \Drupal\Core\Entity\EntityManager
* @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController().
*/
function entity_render_controller($entity_type) {
$info = entity_get_info($entity_type);
$class = $info['render_controller_class'];
return new $class($entity_type);
return drupal_container()->get('plugin.manager.entity')
->getRenderController($entity_type);
}
/**
......@@ -541,7 +528,9 @@ function entity_render_controller($entity_type) {
* A render array for the entity.
*/
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) {
return entity_render_controller($entity->entityType())->view($entity, $view_mode, $langcode);
return drupal_container()->get('plugin.manager.entity')
->getRenderController($entity->entityType())
->view($entity, $view_mode, $langcode);
}
/**
......@@ -560,7 +549,9 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) {
* entities array passed in $entities.
*/
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL) {
return entity_render_controller(reset($entities)->entityType())->viewMultiple($entities, $view_mode, $langcode);
return drupal_container()->get('plugin.manager.entity')
->getRenderController(reset($entities)->entityType())
->viewMultiple($entities, $view_mode, $langcode);
}
/**
......
......@@ -254,7 +254,9 @@ public function getIterator() {
*/
public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) {
$method = $operation . 'Access';
return entity_access_controller($this->entityType)->$method($this, LANGUAGE_DEFAULT, $account);
return drupal_container()->get('plugin.manager.entity')
->getAccessController($this->entityType)
->$method($this, LANGUAGE_DEFAULT, $account);
}
/**
......@@ -325,7 +327,7 @@ public function getTranslationLanguages($include_default = TRUE) {
* Implements EntityInterface::save().
*/
public function save() {
return entity_get_controller($this->entityType)->save($this);
return drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->save($this);
}
/**
......@@ -333,7 +335,7 @@ public function save() {
*/
public function delete() {
if (!$this->isNew()) {
entity_get_controller($this->entityType)->delete(array($this->id() => $this));
drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->delete(array($this->id() => $this));
}
}
......
......@@ -200,6 +200,13 @@ class EntityManager extends PluginManagerBase {
*/
protected $cacheTags = array('entity_info' => TRUE);
/**
* Contains instantiated controllers keyed by controller type and entity type.
*
* @var array
*/
protected $controllers = array();
/**
* The default values for optional keys of the entity plugin definition.
*
......@@ -303,4 +310,129 @@ public function processDefinition(&$definition, $plugin_id) {
}
}
/**
* Returns an entity controller class.
*
* @param string $entity_type
* The name of the entity type
* @param string $controller_type
* The name of the controller.
* @param string|null $nested
* (optional) If this controller definition is nested, the name of the key.
* Defaults to NULL.
*
* @return string
* The class name for this controller instance.
*/
public function getControllerClass($entity_type, $controller_type, $nested = NULL) {
$definition = $this->getDefinition($entity_type);
if (empty($definition[$controller_type])) {
throw new \InvalidArgumentException(sprintf('The entity (%s) did not specify a %s.', $entity_type, $controller_type));
}
$class = $definition[$controller_type];
// Some class definitions can be nested.
if (isset($nested)) {
if (empty($class[$nested])) {
throw new \InvalidArgumentException(sprintf("Missing '%s: %s' for entity '%s'", $controller_type, $nested, $entity_type));
}
$class = $class[$nested];
}
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Entity (%s) %s "%s" does not exist.', $entity_type, $controller_type, $class));
}
return $class;
}
/**
* Creates a new storage controller instance.
*
* @param string $entity_type
* The entity type for this storage controller.
*
* @return \Drupal\Core\Entity\EntityStorageControllerInterface
* A storage controller instance.
*/
public function getStorageController($entity_type) {
if (!isset($this->controllers['storage'][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'controller_class');
$this->controllers['storage'][$entity_type] = new $class($entity_type);
}
return $this->controllers['storage'][$entity_type];
}
/**
* Creates a new list controller instance.
*
* @param string $entity_type
* The entity type for this list controller.
*
* @return \Drupal\Core\Entity\EntityListControllerInterface
* A list controller instance.
*/
public function getListController($entity_type) {
if (!isset($this->controllers['listing'][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'list_controller_class');
$this->controllers['listing'][$entity_type] = new $class($entity_type, $this->getStorageController($entity_type));
}
return $this->controllers['listing'][$entity_type];
}
/**
* Creates a new form controller instance.
*
* @param string $entity_type
* The entity type for this form controller.
* @param string $operation
* The name of the operation to use, e.g., 'default'.
*
* @return \Drupal\Core\Entity\EntityFormControllerInterface
* A form controller instance.
*/
public function getFormController($entity_type, $operation) {
if (!isset($this->controllers['form'][$operation][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'form_controller_class', $operation);
$this->controllers['form'][$operation][$entity_type] = new $class($operation);
}
return $this->controllers['form'][$operation][$entity_type];
}
/**
* Creates a new render controller instance.
*
* @param string $entity_type
* The entity type for this render controller.
*
* @return \Drupal\Core\Entity\EntityRenderControllerInterface.
* A render controller instance.
*/
public function getRenderController($entity_type) {
if (!isset($this->controllers['render'][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'render_controller_class');
$this->controllers['render'][$entity_type] = new $class($entity_type);
}
return $this->controllers['render'][$entity_type];
}
/**
* Creates a new access controller instance.
*
* @param string $entity_type
* The entity type for this access controller.
*
* @return \Drupal\Core\Entity\EntityRenderControllerInterface.
* A access controller instance.
*/
public function getAccessController($entity_type) {
if (!isset($this->controllers['access'][$entity_type])) {
$class = $this->getControllerClass($entity_type, 'access_controller_class');
$this->controllers['access'][$entity_type] = new $class($entity_type);
}
return $this->controllers['access'][$entity_type];
}
}
......@@ -216,7 +216,7 @@ public function getPropertyDefinition($name) {
*/
public function getPropertyDefinitions() {
if (!isset($this->fieldDefinitions)) {
$this->fieldDefinitions = entity_get_controller($this->entityType)->getFieldDefinitions(array(
$this->fieldDefinitions = drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions(array(
'entity type' => $this->entityType,
'bundle' => $this->bundle,
));
......
......@@ -195,8 +195,10 @@ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User
$method = $operation . 'Access';
// @todo Add a way to set and get the langcode so that's more obvious what
// we're doing here.
$langocde = substr($this->getName(), 1);
return entity_access_controller($this->parent->entityType())->$method($this->parent, $langocde, $account);
$langcode = substr($this->getName(), 1);
return drupal_container()->get('plugin.manager.entity')
->getAccessController($this->parent->entityType())
->$method($this->parent, $langcode, $account);
}
/**
......
......@@ -174,7 +174,7 @@ public function getPropertyDefinition($name) {
*/
public function getPropertyDefinitions() {
// @todo: Support getting definitions if multiple bundles are specified.
return entity_get_controller($this->entityType)->getFieldDefinitions($this->definition['constraints']);
return drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions($this->definition['constraints']);
}
/**
......
......@@ -33,7 +33,7 @@ function __construct(ContainerInterface $container) {
* @return QueryInterface
*/
public function get($entity_type, $conjunction = 'AND') {
$service_name = entity_get_controller($entity_type)->getQueryServicename();
$service_name = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type)->getQueryServicename();
return $this->container->get($service_name)->get($entity_type, $conjunction);
}
......
......@@ -29,7 +29,9 @@ function block_admin_demo($theme = NULL) {
* @see block_menu()
*/
function block_admin_display($theme) {
return entity_list_controller('block')->render($theme);
return drupal_container()->get('plugin.manager.entity')
->getListController('block')
->render($theme);
}
/**
......
......@@ -47,7 +47,7 @@ protected function setUp() {
parent::setUp();
$this->enableModules(array('block'));
$this->controller = entity_get_controller('block');
$this->controller = $this->container->get('plugin.manager.entity')->getStorageController('block');
}
/**
......
......@@ -35,7 +35,8 @@ public static function getInfo() {
* Tests entity list controller methods.
*/
function testList() {
$controller = entity_list_controller('config_test');
$controller = $this->container->get('plugin.manager.entity')
->getListController('config_test');
// Test getStorageController() method.
$this->assertTrue($controller->getStorageController() instanceof EntityStorageControllerInterface, 'EntityStorageController instance in storage.');
......
......@@ -33,7 +33,7 @@ public static function getInfo() {
* Tests storage controller methods.
*/
public function testStorageControllerMethods() {
$controller = entity_get_controller('config_test');
$controller = $this->container->get('plugin.manager.entity')->getStorageController('config_test');
$info = entity_get_info('config_test');
$expected = $info['config_prefix'] . '.';
......
......@@ -71,8 +71,9 @@ function config_test_load($id) {
* Page callback; Lists available ConfigTest objects.
*/
function config_test_list_page() {
$controller = entity_list_controller('config_test');
return $controller->render();
return drupal_container()->get('plugin.manager.entity')
->getListController('config_test')
->render();
}
/**
......
......@@ -17,7 +17,9 @@
*/
function contact_category_list() {
drupal_set_title(t('Contact form categories'));
return entity_list_controller('contact_category')->render();
return drupal_container()->get('plugin.manager.entity')
->getListController('contact_category')
->render();
}
/**
......
......@@ -100,7 +100,7 @@ function testFieldFormSingle() {
$edit = array("{$this->field_name}[$langcode][0][value]" => $value);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
entity_get_controller('test_entity')->resetCache(array($id));
$this->container->get('plugin.manager.entity')->getStorageController('test_entity')->resetCache(array($id));
$entity = field_test_entity_test_load($id);
$this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was updated');
......@@ -109,7 +109,7 @@ function testFieldFormSingle() {
$edit = array("{$this->field_name}[$langcode][0][value]" => $value);
$this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save'));
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
entity_get_controller('test_entity')->resetCache(array($id));
$this->container->get('plugin.manager.entity')->getStorageController('test_entity')->resetCache(array($id));
$entity = field_test_entity_test_load($id);
$this->assertIdentical($entity->{$this->field_name}, array(), 'Field was emptied');
}
......@@ -458,7 +458,7 @@ function testFieldFormAccess() {
$this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save'));
// Check that the new revision has the expected values.
entity_get_controller('test_entity')->resetCache(array($id));
$this->container->get('plugin.manager.entity')->getStorageController('test_entity')->resetCache(array($id));
$entity = field_test_entity_test_load($id);
$this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.');
$this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.');
......
......@@ -399,7 +399,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
}
// Save a query by only calling spaceUsed() when a limit is provided.
if ($user_limit && (entity_get_controller('file')->spaceUsed($user->uid) + $file->filesize) > $user_limit) {
if ($user_limit && (drupal_container()->get('plugin.manager.entity')->getStorageController('file')->spaceUsed($user->uid) + $file->filesize) > $user_limit) {
$errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
}
......@@ -701,7 +701,7 @@ function file_file_download($uri, $field_type = 'file') {
* Implements file_cron()
*/
function file_cron() {
$result = entity_get_controller('file')->retrieveTemporaryFiles();
$result = drupal_container()->get('plugin.manager.entity')->getStorageController('file')->retrieveTemporaryFiles();
foreach ($result as $row) {
if ($file = file_load($row->fid)) {
$references = file_usage()->listUsage($file);
......
......@@ -193,7 +193,7 @@ function assertFileExists($file, $message = NULL) {
* Asserts that a file exists in the database.
*/
function assertFileEntryExists($file, $message = NULL) {
entity_get_controller('file')->resetCache();
$this->container->get('plugin.manager.entity')->getStorageController('file')->resetCache();
$db_file = file_load($file->fid);
$message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri));
$this->assertEqual($db_file->uri, $file->uri, $message);
......@@ -211,7 +211,7 @@ function assertFileNotExists($file, $message = NULL) {
* Asserts that a file does not exist in the database.
*/
function assertFileEntryNotExists($file, $message) {
entity_get_controller('file')->resetCache();
$this->container->get('plugin.manager.entity')->getStorageController('file')->resetCache();
$message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri));
$this->assertFalse(file_load($file->fid), $message);
}
......
......@@ -43,7 +43,7 @@ function setUp() {
* Test different users with the default status.
*/
function testFileSpaceUsed() {
$file = entity_get_controller('file');
$file = $this->container->get('plugin.manager.entity')->getStorageController('file');
// Test different users with default status.
$this->assertEqual($file->spaceUsed(2), 70);
$this->assertEqual($file->spaceUsed(3), 300);
......
......@@ -340,7 +340,7 @@ function editForumTaxonomy() {
$this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), 'Vocabulary was edited');
// Grab the newly edited vocabulary.
entity_get_controller('taxonomy_vocabulary')->resetCache();
$this->container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary')->resetCache();
$current_settings = taxonomy_vocabulary_load($vid);
// Make sure we actually edited the vocabulary properly.
......
......@@ -468,7 +468,7 @@ function testLinkSeparateFormatter() {
*/
protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
if ($reset) {
entity_get_controller('test_entity')->resetCache(array($id));
$this->container->get('plugin.manager.entity')->getStorageController('test_entity')->resetCache(array($id));
}
$entity = field_test_entity_test_load($id);
$display = entity_get_display($entity->entityType(), $entity->bundle(), $view_mode);
......
......@@ -12,7 +12,9 @@
* Menu callback which shows an overview page of all the custom menus and their descriptions.
*/
function menu_overview_page() {
return entity_list_controller('menu')->render();
return drupal_container()->get('plugin.manager.entity')
->getListController('menu')
->render();
}
/**
......
......@@ -35,8 +35,9 @@ function testSummaryLength() {
$web_user = $this->drupalCreateUser(array('access content', 'administer content types'));
$this->loggedInUser = $web_user;
$controller = $this->container->get('plugin.manager.entity')->getRenderController('node');
// Render the node as a teaser.
$content = entity_render_controller('node')->view($node, 'teaser');
$content = $controller->view($node, 'teaser');
$this->assertTrue(strlen($content['body'][0]['#markup']) < 600, 'Teaser is less than 600 characters long.');
$this->drupalSetContent(drupal_render($content));
// The string 'What is a Drupalism?' is between the 200th and 600th
......@@ -54,7 +55,7 @@ function testSummaryLength() {
// Render the node as a teaser again and check that the summary is now only
// 200 characters in length and so does not include 'What is a Drupalism?'.
$content = entity_render_controller('node')->view($node, 'teaser');
$content = $controller->view($node, 'teaser');
$this->assertTrue(strlen($content['body'][0]['#markup']) < 200, 'Teaser is less than 200 characters long.');
$this->drupalSetContent(drupal_render($content));
$this->assertText($node->label());
......
......@@ -16,8 +16,9 @@
* @see picture_menu()
*/
function picture_mapping_page() {
$controller = entity_list_controller('picture_mapping');
return $controller->render();
return drupal_container()->get('plugin.manager.entity')
->getListController('picture_mapping')
->render();
}
/**
......
......@@ -176,7 +176,7 @@ function __construct($test_id = NULL) {
*/
function drupalGetNodeByTitle($title, $reset = FALSE) {
if ($reset) {
entity_get_controller('node')->resetCache();
drupal_container()->get('plugin.manager.entity')->getStorageController('node')->resetCache();
}
$nodes = entity_load_multiple_by_properties('node', array('title' => $title));
// Load the first node returned from the database.
......
......@@ -84,7 +84,7 @@ function testEntityAccess() {
function testEntityAccessDefaultController() {
// Check that the default access controller is used for entities that don't
// have a specific access controller defined.
$controller = entity_access_controller('entity_test_default_access');
$controller = $this->container->get('plugin.manager.entity')->getAccessController('entity_test_default_access');
$this->assertTrue($controller instanceof EntityAccessController, 'The default entity controller is used for the entity_test_default_access entity type.');
$entity = entity_create('entity_test_default_access', array());
......
......@@ -85,7 +85,7 @@ protected function assertFormCRUD($entity_type) {
protected function loadEntityByName($entity_type, $name) {
// Always load the entity from the database to ensure that changes are
// correctly picked up.
entity_get_controller($entity_type)->resetCache();
$this->container->get('plugin.manager.entity')->getStorageController($entity_type)->resetCache();
return current(entity_load_multiple_by_properties($entity_type, array('name' => $name)));
}
}
......@@ -96,7 +96,7 @@ function testTaxonomyAdminChangingWeights() {
$this->drupalPost('admin/structure/taxonomy', $edit, t('Save'));
// Load the vocabularies from the database.
entity_get_controller('taxonomy_vocabulary')->resetCache();
$this->container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary')->resetCache();
$new_vocabularies = taxonomy_vocabulary_load_multiple();
taxonomy_vocabulary_sort($new_vocabularies);
......@@ -136,7 +136,7 @@ function testTaxonomyAdminDeletingVocabulary() {
$this->assertText(t('Created new vocabulary'), 'New vocabulary was created.');