Commit 58de5374 authored by Dries's avatar Dries

Issue #2024833 by claudiu.cristea: Adopt load() and loadMultiple() on entity storage controllers.

parent d988a30f
......@@ -2550,12 +2550,12 @@ function language_default_locked_languages($weight = 0) {
* @param string $langcode
* The language code.
*
* @return Drupal\core\Language\Language | FALSE
* A fully-populated language object or FALSE.
* @return \Drupal\core\Language\Language|null
* A fully-populated language object or NULL.
*/
function language_load($langcode) {
$languages = language_list(Language::STATE_ALL);
return isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
return isset($languages[$langcode]) ? $languages[$langcode] : NULL;
}
/**
......
......@@ -192,17 +192,19 @@ function entity_get_view_modes($entity_type = NULL) {
* Whether to reset the internal cache for the requested entity type.
*
* @return Drupal\Core\Entity\EntityInterface
* The entity object, or FALSE if there is no entity with the given id.
* The entity object, or NULL if there is no entity with the given id.
*
* @see \Drupal\Core\Entity\EntityManager
* @see entity_load_multiple()
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
* @see Drupal\Core\Entity\Query\QueryInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\Query\QueryInterface
*/
function entity_load($entity_type, $id, $reset = FALSE) {
$entities = entity_load_multiple($entity_type, array($id), $reset);
return isset($entities[$id]) ? $entities[$id] : FALSE;
$controller = Drupal::entityManager()->getStorageController($entity_type);
if ($reset) {
$controller->resetCache(array($id));
}
return $controller->load($id);
}
/**
......@@ -218,8 +220,8 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* id.
*
* @see \Drupal\Core\Entity\EntityManager
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
*/
function entity_revision_load($entity_type, $revision_id) {
return Drupal::entityManager()
......@@ -305,16 +307,16 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
* An array of entity objects indexed by their ids.
*
* @see \Drupal\Core\Entity\EntityManager
* @see Drupal\Core\Entity\EntityStorageControllerInterface
* @see Drupal\Core\Entity\DatabaseStorageController
* @see Drupal\Core\Entity\Query\QueryInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\Query\QueryInterface
*/
function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
$controller = Drupal::entityManager()->getStorageController($entity_type);
if ($reset) {
$controller->resetCache();
$controller->resetCache($ids);
}
return $controller->load($ids);
return $controller->loadMultiple($ids);
}
/**
......@@ -367,7 +369,7 @@ function entity_load_unchanged($entity_type, $id) {
*/
function entity_delete_multiple($entity_type, array $ids) {
$controller = Drupal::entityManager()->getStorageController($entity_type);
$entities = $controller->load($ids);
$entities = $controller->loadMultiple($ids);
$controller->delete($entities);
}
......
......@@ -559,7 +559,7 @@ function _menu_load_objects(&$item, &$map) {
$return = $function($value);
}
// If callback returned an error or there is no callback, trigger 404.
if ($return === FALSE) {
if (empty($return)) {
$item['access'] = FALSE;
$map = FALSE;
return FALSE;
......
......@@ -114,9 +114,9 @@ public static function createInstance(ContainerInterface $container, $entity_typ
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::load().
* {@inheritdoc}
*/
public function load(array $ids = NULL) {
public function loadMultiple(array $ids = NULL) {
$entities = array();
// Create a new variable which is either a prepared version of the $ids
......@@ -152,6 +152,14 @@ public function load(array $ids = NULL) {
return $entities;
}
/**
* {@inheritdoc}
*/
public function load($id) {
$entities = $this->loadMultiple(array($id));
return isset($entities[$id]) ? $entities[$id] : NULL;
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
*/
......@@ -170,7 +178,7 @@ public function deleteRevision($revision_id) {
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadByProperties().
*/
public function loadByProperties(array $values = array()) {
$entities = $this->load();
$entities = $this->loadMultiple();
foreach ($values as $key => $value) {
$entities = array_filter($entities, function($entity) use ($key, $value) {
return $value === $entity->get($key);
......@@ -386,8 +394,7 @@ public function save(EntityInterface $entity) {
if (!$is_new && !isset($entity->original)) {
$this->resetCache(array($id));
$result = $this->load(array($id));
$entity->original = reset($result);
$entity->original = $this->load($id);
}
if ($id !== $entity->id()) {
......@@ -492,8 +499,7 @@ public function importCreate($name, Config $new_config, Config $old_config) {
*/
public function importUpdate($name, Config $new_config, Config $old_config) {
$id = static::getIDFromConfigName($name, $this->entityInfo['config_prefix']);
$entities = $this->load(array($id));
$entity = $entities[$id];
$entity = $this->load($id);
$entity->original = clone $entity;
foreach ($old_config->get() as $property => $value) {
......@@ -523,8 +529,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) {
*/
public function importDelete($name, Config $new_config, Config $old_config) {
$id = static::getIDFromConfigName($name, $this->entityInfo['config_prefix']);
$entities = $this->load(array($id));
$entity = $entities[$id];
$entity = $this->load($id);
$entity->delete();
return TRUE;
}
......
......@@ -111,9 +111,9 @@ public function __construct($entity_type, array $entity_info, Connection $databa
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::load().
* {@inheritdoc}
*/
public function load(array $ids = NULL) {
public function loadMultiple(array $ids = NULL) {
$entities = array();
// Create a new variable which is either a prepared version of the $ids
......@@ -177,6 +177,14 @@ public function load(array $ids = NULL) {
return $entities;
}
/**
* {@inheritdoc}
*/
public function load($id) {
$entities = $this->loadMultiple(array($id));
return isset($entities[$id]) ? $entities[$id] : NULL;
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
*/
......@@ -227,7 +235,7 @@ public function loadByProperties(array $values = array()) {
$entity_query = \Drupal::entityQuery($this->entityType);
$this->buildPropertyQuery($entity_query, $values);
$result = $entity_query->execute();
return $result ? $this->load($result) : array();
return $result ? $this->loadMultiple($result) : array();
}
/**
......
......@@ -87,7 +87,7 @@ public function getStorageController() {
* Implements \Drupal\Core\Entity\EntityListControllerInterface::load().
*/
public function load() {
return $this->storage->load();
return $this->storage->loadMultiple();
}
/**
......
......@@ -89,8 +89,7 @@ public function __construct($entity_type, $entity_info) {
*/
public function loadUnchanged($id) {
$this->resetCache(array($id));
$result = $this->load(array($id));
return reset($result);
return $this->load($id);
}
/**
......
......@@ -38,7 +38,18 @@ public function resetCache(array $ids = NULL);
* @return
* An array of entity objects indexed by their ids.
*/
public function load(array $ids = NULL);
public function loadMultiple(array $ids = NULL);
/**
* Loads one entity.
*
* @param mixed $id
* The ID of the entity to load.
*
* @return \Drupal\Core\Entity\EntityInterface
* An entity object.
*/
public function load($id);
/**
* Loads an unchanged entity from the database.
......
......@@ -92,10 +92,7 @@ public function process(array &$variables, Route $route, array &$converted) {
$value = $variables[$name];
$storageController = $this->entityManager->getStorageController($type);
$entities = $storageController->load(array($value));
// Make sure $entities is null, if upcasting fails.
$entity = $entities ? reset($entities) : NULL;
$entity = $storageController->load($value);
$variables[$name] = $entity;
// Mark this variable as converted.
......
......@@ -114,8 +114,8 @@ public function form(array $form, array &$form_state) {
* TRUE if the action exists, FALSE otherwise.
*/
public function exists($id) {
$actions = $this->storageController->load(array($id));
return isset($actions[$id]);
$action = $this->storageController->load($id);
return !empty($action);
}
/**
......
......@@ -283,7 +283,7 @@ public function pageLast() {
*/
public function sources() {
$feeds = $this->entityManager->getStorageController('aggregator_feed')->load();
$feeds = $this->entityManager->getStorageController('aggregator_feed')->loadMultiple();
$build = array(
'#type' => 'container',
......
......@@ -202,7 +202,7 @@ public function submitForm(array &$form, array &$form_state) {
->execute();
$result = $this->entityManager
->getStorageController('aggregator_feed')
->load($ids);
->loadMultiple($ids);
foreach ($result as $old) {
if (strcasecmp($old->label(), $feed['title']) == 0) {
drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->label())), 'warning');
......
......@@ -59,7 +59,7 @@ public static function create(ContainerInterface $container, array $configuratio
function titleQuery() {
$titles = array();
$feeds = $this->entityManager->getStorageController('aggregator_feed')->load($this->value);
$feeds = $this->entityManager->getStorageController('aggregator_feed')->loadMultiple($this->value);
foreach ($feeds as $feed) {
$titles[] = String::checkPlain($feed->label());
}
......
......@@ -59,7 +59,7 @@ public static function create(ContainerInterface $container, array $configuratio
function titleQuery() {
$titles = array();
$items = $this->entityManager->getStorageController('aggregator_item')->load($this->value);
$items = $this->entityManager->getStorageController('aggregator_item')->loadMultiple($this->value);
foreach ($items as $feed) {
$titles[] = String::checkPlain($feed->label());
}
......
......@@ -121,8 +121,8 @@ function custom_block_theme($existing, $type, $theme, $path) {
* @param int $id
* The ID of the custom block type to load.
*
* @return Drupal\custom_block\Plugin\Core\Entity\CustomBlockType|false
* A CustomBlockType object or FALSE if the requested $id does not exist.
* @return \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType|null
* A CustomBlockType object or NULL if the requested $id does not exist.
*/
function custom_block_type_load($id) {
return entity_load('custom_block_type', $id);
......@@ -134,8 +134,8 @@ function custom_block_type_load($id) {
* @param int $id
* The id of the custom block.
*
* @return Drupal\custom_block\Plugin\Core\Entity\CustomBlock|false
* A CustomBlock object or FALSE if the requested $id does not exist.
* @return \Drupal\custom_block\Plugin\Core\Entity\CustomBlock|null
* A CustomBlock object or NULL if the requested $id does not exist.
*/
function custom_block_load($id) {
return entity_load('custom_block', $id);
......
......@@ -77,7 +77,7 @@ public function __construct(PluginManagerInterface $entity_manager, EntityStorag
* returns the custom block add page for that custom block type.
*/
public function add(Request $request) {
$types = $this->customBlockTypeStorage->load();
$types = $this->customBlockTypeStorage->loadMultiple();
if ($types && count($types) == 1) {
$type = reset($types);
return $this->addForm($type, $request);
......
......@@ -18,8 +18,8 @@ class BlockStorageController extends ConfigStorageController {
/**
* {@inheritdoc}
*/
public function load(array $ids = NULL) {
$entities = parent::load($ids);
public function loadMultiple(array $ids = NULL) {
$entities = parent::loadMultiple($ids);
// Only blocks with a valid plugin should be loaded.
return array_filter($entities, function ($entity) {
return $entity->getPlugin();
......
......@@ -116,8 +116,7 @@ protected function createTests() {
* Tests the rendering of blocks.
*/
protected function loadTests() {
$entities = $this->controller->load(array('stark.test_block'));
$entity = reset($entities);
$entity = $this->controller->load('stark.test_block');
$this->assertTrue($entity instanceof Block, 'The loaded entity is a Block.');
......@@ -182,8 +181,7 @@ protected function renderTests() {
* Tests the deleting of blocks.
*/
protected function deleteTests() {
$entities = $this->controller->load(array('stark.test_block'));
$entity = reset($entities);
$entity = $this->controller->load('stark.test_block');
// Ensure that the storage isn't currently empty.
$config_storage = $this->container->get('config.storage');
......@@ -202,13 +200,13 @@ protected function deleteTests() {
* Tests the installation of default blocks.
*/
public function testDefaultBlocks() {
$entities = $this->controller->load();
$entities = $this->controller->loadMultiple();
$this->assertTrue(empty($entities), 'There are no blocks initially.');
// Install the block_test.module, so that its default config is installed.
$this->installConfig(array('block_test'));
$entities = $this->controller->load();
$entities = $this->controller->loadMultiple();
$entity = reset($entities);
$this->assertEqual($entity->id(), 'stark.test_block', 'The default test block was loaded.');
}
......
......@@ -75,10 +75,10 @@ protected function testDeleteBlockDisplay() {
$view->displayHandlers->remove('block_1');
$view->storage->save();
$this->assertFalse($block_storage_controller->load(array($block_1->id())), 'The block for this display was removed.');
$this->assertFalse($block_storage_controller->load(array($block_2->id())), 'The block for this display was removed.');
$this->assertTrue($block_storage_controller->load(array($block_3->id())), 'A block from another view was unaffected.');
$this->assertTrue($block_storage_controller->load(array($block_4->id())), 'A block from another view was unaffected.');
$this->assertFalse($block_storage_controller->load($block_1->id()), 'The block for this display was removed.');
$this->assertFalse($block_storage_controller->load($block_2->id()), 'The block for this display was removed.');
$this->assertTrue($block_storage_controller->load($block_3->id()), 'A block from another view was unaffected.');
$this->assertTrue($block_storage_controller->load($block_4->id()), 'A block from another view was unaffected.');
$this->drupalGet('test-page');
$this->assertNoBlockAppears($block_1);
$this->assertNoBlockAppears($block_2);
......@@ -92,8 +92,8 @@ protected function testDeleteBlockDisplay() {
$view->displayHandlers->remove('block_1');
$view->storage->save();
$this->assertFalse($block_storage_controller->load(array($block_3->id())), 'The block for this display was removed.');
$this->assertTrue($block_storage_controller->load(array($block_4->id())), 'A block from another display on the same view was unaffected.');
$this->assertFalse($block_storage_controller->load($block_3->id()), 'The block for this display was removed.');
$this->assertTrue($block_storage_controller->load($block_4->id()), 'A block from another display on the same view was unaffected.');
$this->drupalGet('test-page');
$this->assertNoBlockAppears($block_3);
$this->assertBlockAppears($block_4);
......@@ -114,18 +114,18 @@ public function testViewsBlockForm() {
// Save the block.
$this->drupalPost(NULL, array(), t('Save block'));
$storage = $this->container->get('plugin.manager.entity')->getStorageController('block');
$blocks = $storage->load(array('stark.views_block__test_view_block_block_1'));
$block = $storage->load('stark.views_block__test_view_block_block_1');
// This will only return a result if our new block has been created with the
// expected machine name.
$this->assertTrue(!empty($blocks), 'The expected block was loaded.');
$this->assertTrue(!empty($block), 'The expected block was loaded.');
for ($i = 2; $i <= 3; $i++) {
// Place the same block again and make sure we have a new ID.
$this->drupalPost('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, array(), t('Save block'));
$blocks = $storage->load(array('stark.views_block__test_view_block_block_1_' . $i));
$block = $storage->load('stark.views_block__test_view_block_block_1_' . $i);
// This will only return a result if our new block has been created with the
// expected machine name.
$this->assertTrue(!empty($blocks), 'The expected block was loaded.');
$this->assertTrue(!empty($block), 'The expected block was loaded.');
}
}
......
......@@ -79,7 +79,7 @@ protected function loadBooks() {
$query->addMetaData('base_table', 'book');
$book_links = $query->execute();
$nodes = $this->entityManager->getStorageController('node')->load($nids);
$nodes = $this->entityManager->getStorageController('node')->loadMultiple($nids);
foreach ($book_links as $link) {
$nid = $link['nid'];
......
......@@ -294,8 +294,8 @@ function breakpoint_get_module_media_queries($module) {
* @param string $id
* The id of the breakpoint group to load.
*
* @return Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroup|false
* The breakpoint group, or FALSE if there is no entity with the given id.
* @return \Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroup|null
* The breakpoint group, or NULL if there is no entity with the given id.
*
* @todo Remove this in a follow-up issue.
* @see http://drupal.org/node/1798214
......@@ -310,8 +310,8 @@ function breakpoint_group_load($id) {
* @param int $id
* The id of the breakpoint to load.
*
* @return Drupal\breakpoint\Plugin\Core\Entity\Breakpoint
* The entity object, or FALSE if there is no entity with the given id.
* @return \Drupal\breakpoint\Plugin\Core\Entity\Breakpoint|null
* The entity object, or NULL if there is no entity with the given id.
*
* @todo Remove this in a follow-up issue.
* @see http://drupal.org/node/1798214
......
......@@ -1195,7 +1195,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
// edit could change the security situation so it is not safe to index the
// comments.
$index_comments = TRUE;
$roles = Drupal::entityManager()->getStorageController('user_role')->load();
$roles = Drupal::entityManager()->getStorageController('user_role')->loadMultiple();
$authenticated_can_access = $roles[DRUPAL_AUTHENTICATED_RID]->hasPermission('access comments');
foreach ($roles as $rid => $role) {
if ($role->hasPermission('search content') && !$role->hasPermission('access comments')) {
......
......@@ -232,8 +232,8 @@ function contact_field_extra_fields() {
* @param $id
* The ID of the contact category to load.
*
* @return Drupal\contact\Plugin\Core\Entity\Category|false
* A Category object or FALSE if the requested $id does not exist.
* @return \Drupal\contact\Plugin\Core\Entity\Category|null
* A Category object or NULL if the requested $id does not exist.
*/
function contact_category_load($id) {
return entity_load('contact_category', $id);
......
......@@ -290,7 +290,7 @@ function editor_form_filter_admin_format_validate($form, &$form_state) {
// 'Configure' button won't be clicked automatically. So, when the user has
// selected a text editor and has then clicked 'Save configuration', we should
// point out that the user must still configure the text editor.
if ($form_state['values']['editor']['editor'] !== '' && $form_state['editor'] === FALSE) {
if ($form_state['values']['editor']['editor'] !== '' && empty($form_state['editor'])) {
form_set_error('editor][editor', t('You must configure the selected text editor.'));
}
}
......@@ -307,7 +307,7 @@ function editor_form_filter_admin_format_submit($form, &$form_state) {
}
// Create a new editor or update the existing editor.
if ($form_state['editor'] !== FALSE) {
if (!empty($form_state['editor'])) {
// Ensure the text format is set: when creating a new text format, this
// would equal the empty string.
$form_state['editor']->format = $format_id;
......@@ -319,8 +319,8 @@ function editor_form_filter_admin_format_submit($form, &$form_state) {
/**
* Loads an individual configured text editor based on text format ID.
*
* @return \Drupal\editor\Plugin\Core\Entity\Editor|FALSE
* A text editor object, or FALSE.
* @return \Drupal\editor\Plugin\Core\Entity\Editor|null
* A text editor object, or NULL.
*/
function editor_load($format_id) {
// Load all the editors at once here, assuming that either no editors or more
......@@ -328,7 +328,7 @@ function editor_load($format_id) {
// formats for administrators). Loading a small number of editors all at once
// is more efficient than loading multiple editors individually.
$editors = entity_load_multiple('editor');
return isset($editors[$format_id]) ? $editors[$format_id] : FALSE;
return isset($editors[$format_id]) ? $editors[$format_id] : NULL;
}
/**
......
......@@ -65,8 +65,7 @@ public function getMatches($field, $instance, $entity_type, $entity_id = '', $pr
$entity = NULL;
if ($entity_id !== 'NULL') {
$entities = $this->entityManager->getStorageController($entity_type)->load(array($entity_id));
$entity = reset($entities);
$entity = $this->entityManager->getStorageController($entity_type)->load($entity_id);
if (!$entity || !$entity->access('view')) {
throw new AccessDeniedHttpException();
}
......
......@@ -117,11 +117,12 @@ public function loadByProperties(array $conditions = array()) {
// Get instances stored in configuration.
if (isset($conditions['entity_type']) && isset($conditions['bundle']) && isset($conditions['field_name'])) {
// Optimize for the most frequent case where we do have a specific ID.
$instances = $this->entityManager->getStorageController($this->entityType)->load(array($conditions['entity_type'] . '.' . $conditions['bundle'] . '.' . $conditions['field_name']));
$id = $conditions['entity_type'] . '.' . $conditions['bundle'] . '.' . $conditions['field_name'];
$instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($id));
}
else {
// No specific ID, we need to examine all existing instances.
$instances = $this->entityManager->getStorageController($this->entityType)->load();
$instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple();
}
// Merge deleted instances (stored in state) if needed.
......
......@@ -100,11 +100,11 @@ public function loadByProperties(array $conditions = array()) {
// Get fields stored in configuration.
if (isset($conditions['field_name'])) {
// Optimize for the most frequent case where we do have a specific ID.
$fields = $this->entityManager->getStorageController($this->entityType)->load(array($conditions['field_name']));
$fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($conditions['field_name']));
}
else {
// No specific ID, we need to examine all existing fields.
$fields = $this->entityManager->getStorageController($this->entityType)->load();
$fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple();
}
// Merge deleted fields (stored in state) if needed.
......
......@@ -335,7 +335,7 @@ protected function saveNew() {
}
// Ensure the field name is unique (we do not care about deleted fields).
if ($prior_field = current($storage_controller->load(array($this->id)))) {
if ($prior_field = $storage_controller->load($this->id)) {
$message = $prior_field->active ?
'Attempt to create field name %id which already exists and is active.' :
'Attempt to create field name %id which already exists, although it is inactive.';
......@@ -455,7 +455,7 @@ public function delete() {
$instance_ids[] = "$entity_type.$bundle.$this->id";
}
}
foreach ($instance_controller->load($instance_ids) as $instance) {
foreach ($instance_controller->loadMultiple($instance_ids) as $instance) {
// By default, FieldInstance::delete() will automatically try to delete
// a field definition when it is deleting the last instance of the
// field. Since the whole field is being deleted here, pass FALSE as
......
......@@ -364,7 +364,7 @@ protected function saveNew() {
$this->id = $this->id();
// Ensure the field instance is unique within the bundle.
if ($prior_instance = current($instance_controller->load(array($this->id)))) {
if ($prior_instance = $instance_controller->load($this->id)) {
throw new FieldException(format_string('Attempt to create an instance of field @field_id on bundle @bundle that already has an instance of that field.', array('@field_id' => $this->field->id, '@bundle' => $this->bundle)));
}
......
......@@ -119,14 +119,13 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) {
* Whether to reset the internal file_load_multiple() cache.
*
* @return \Drupal\file\FileInterface
* A file entity or FALSE if the file was not found.
* A file entity or NULL if the file was not found.
*
* @see hook_file_load()
* @see file_load_multiple()
*/
function file_load($fid, $reset = FALSE) {
$files = file_load_multiple(array($fid), $reset);
return reset($files);
return entity_load('file', $fid, $reset);
}
/**
......
......@@ -178,7 +178,7 @@ function filter_local_actions() {
* @return
* A fully-populated text format object, if the requested format exists and
* is enabled. If the format does not exist, or exists in the database but
* has been marked as disabled, FALSE is returned.
* has been marked as disabled, NULL is returned.
*
* @see filter_format_exists()
*
......@@ -186,7 +186,7 @@ function filter_local_actions() {
*/
function filter_format_load($format_id) {
$formats = filter_formats();
return isset($formats[$format_id]) ? $formats[$format_id] : FALSE;
return isset($formats[$format_id]) ? $formats[$format_id] : NULL;
}
/**
......
......@@ -194,7 +194,7 @@ public function validateForm(array &$form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
$values = $form_state['values']['formats'];
$entities = $this->storage->load(array_keys($values));
$entities = $this->storage->loadMultiple(array_keys($values));
foreach ($values as $id => $value) {
if (isset($entities[$id]) && $value['weight'] != $entities[$id]->get('weight')) {
// Update changed weight.
......
......@@ -81,8 +81,7 @@ public function build(array $attributes) {
* Builds the breadcrumb for a forum post page.
*/
protected function forumPostBreadcrumb($node) {
$vocabularies = $this->entityManager->getStorageController('taxonomy_vocabulary')->load(array($this->config->get('vocabulary')));
$vocabulary = reset($vocabularies);
$vocabulary = $this->entityManager->getStorageController('taxonomy_vocabulary')->load($this->config->get('vocabulary'));
$breadcrumb[] = l(t('Home'), NULL);
$breadcrumb[] = l($vocabulary->label(), 'forum');
......@@ -99,8 +98,7 @@ protected function forumPostBreadcrumb($node) {
* Builds the breadcrumb for a forum term page.
*/
protected function forumTermBreadcrumb($term) {
$vocabularies = $this->entityManager->getStorageController('taxonomy_vocabulary')->load(array($this->config->get('vocabulary')));
$vocabulary = current($vocabularies);
$vocabulary = $this->entityManager->getStorageController('taxonomy_vocabulary')->load($this->config->get('vocabulary'));
$breadcrumb[] = l(t('Home'), NULL);
if ($term->tid) {
......
......@@ -772,7 +772,7 @@ function image_effect_definitions() {
*/
function image_effect_definition_load($effect) {
$definitions = image_effect_definitions();
return isset($definitions[$effect]) ? $definitions[$effect] : FALSE;
return isset($definitions[$effect]) ? $definitions[$effect] : NULL;
}
/**
......@@ -790,7 +790,7 @@ function image_effect_definition_load($effect) {
* - "name": The name of the effect definition that powers this image effect.
* - "data": An array of configuration options for this image effect.
* Besides these keys, the entirety of the image definition is merged into
* the image effect array. Returns FALSE if the specified effect cannot be
* the image effect array. Returns NULL if the specified effect cannot be