Commit 6b70606d authored by catch's avatar catch

Issue #2723567 by snehi, Ashish.Dalvi, marvin_B8, John Cook: Remove...

Issue #2723567 by snehi, Ashish.Dalvi, marvin_B8, John Cook: Remove entity_load* usage for entity_view_display entity type
parent 85fa3171
......@@ -462,7 +462,7 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
*/
function entity_get_display($entity_type, $bundle, $view_mode) {
// Try loading the display from configuration.
$display = entity_load('entity_view_display', $entity_type . '.' . $bundle . '.' . $view_mode);
$display = EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . $view_mode);
// If not found, create a fresh display object. We do not preemptively create
// new entity_view_display configuration entries for each existing entity type
......
......@@ -135,7 +135,10 @@ function testFormatterUI() {
$this->drupalPostForm(NULL, array(), t('Save'));
\Drupal::entityManager()->clearCachedFieldDefinitions();
$display = entity_load('entity_view_display', 'node.' . $this->type . '.default', TRUE);
$id = 'node.' . $this->type . '.default';
$storage = $this->container->get('entity_type.manager')->getStorage('entity_view_display');
$storage->resetCache([$id]);
$display = $storage->load($id);
$this->assertEqual($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'), 'foo');
$this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'The display has a dependency on field_third_party_test module.');
......
......@@ -67,7 +67,7 @@ public function testEntityDisplayCRUD() {
// Check that the display can be properly saved and read back.
$display->save();
$display = entity_load('entity_view_display', $display->id());
$display = EntityViewDisplay::load($display->id());
foreach (array('component_1', 'component_2', 'component_3') as $name) {
$this->assertEqual($display->getComponent($name), $expected[$name]);
}
......@@ -95,7 +95,7 @@ public function testEntityDisplayCRUD() {
// Check that the removal is correctly persisted.
$display->save();
$display = entity_load('entity_view_display', $display->id());
$display = EntityViewDisplay::load($display->id());
$this->assertNULL($display->getComponent('component_3'));
// Check that createCopy() creates a new component that can be correctly
......@@ -103,7 +103,7 @@ public function testEntityDisplayCRUD() {
EntityViewMode::create(array('id' => $display->getTargetEntityTypeId() . '.other_view_mode', 'targetEntityType' => $display->getTargetEntityTypeId()))->save();
$new_display = $display->createCopy('other_view_mode');
$new_display->save();
$new_display = entity_load('entity_view_display', $new_display->id());
$new_display = EntityViewDisplay::load($new_display->id());
$dependencies = $new_display->calculateDependencies()->getDependencies();
$this->assertEqual(array('config' => array('core.entity_view_mode.entity_test.other_view_mode'), 'module' => array('entity_test')), $dependencies);
$this->assertEqual($new_display->getTargetEntityTypeId(), $display->getTargetEntityTypeId());
......@@ -283,7 +283,7 @@ public function testBaseFieldComponent() {
$this->assertFalse(isset($data['hidden']['test_display_non_configurable']));
// Check that defaults are correctly filled when loading the display.
$display = entity_load('entity_view_display', $display->id());
$display = EntityViewDisplay::load($display->id());
foreach ($expected as $field_name => $options) {
$this->assertEqual($display->getComponent($field_name), $options);
}
......@@ -293,7 +293,7 @@ public function testBaseFieldComponent() {
$data['content']['test_display_non_configurable'] = $expected['test_display_non_configurable'];
$data['content']['test_display_non_configurable']['weight']++;
$config->setData($data)->save();
$display = entity_load('entity_view_display', $display->id());
$display = EntityViewDisplay::load($display->id());
foreach ($expected as $field_name => $options) {
$this->assertEqual($display->getComponent($field_name), $options);
}
......@@ -312,7 +312,7 @@ public function testDeleteBundle() {
// Delete the bundle.
$type->delete();
$display = entity_load('entity_view_display', 'node.article.default');
$display = EntityViewDisplay::load('node.article.default');
$this->assertFalse((bool) $display);
$form_display = EntityFormDisplay::load('node.article.default');
$this->assertFalse((bool) $form_display);
......
......@@ -4,7 +4,6 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
use Drupal\Core\Routing\RequestHelper;
......@@ -17,7 +16,7 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
/**
* Defines an image style configuration entity.
*
......@@ -138,7 +137,7 @@ protected static function replaceImageStyle(ImageStyleInterface $style) {
if ($style->id() != $style->getOriginalId()) {
// Loop through all entity displays looking for formatters / widgets using
// the image style.
foreach (entity_load_multiple('entity_view_display') as $display) {
foreach (EntityViewDisplay::loadMultiple() as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image' && $options['settings']['image_style'] == $style->getOriginalId()) {
$options['settings']['image_style'] = $style->id();
......@@ -147,7 +146,7 @@ protected static function replaceImageStyle(ImageStyleInterface $style) {
}
}
}
foreach (EntityFormDisplay::loadMultiple() as $display) {
foreach (EntityViewDisplay::loadMultiple() as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image_image' && $options['settings']['preview_image_style'] == $style->getOriginalId()) {
$options['settings']['preview_image_style'] = $style->id();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment