diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 0177326..ddf95f3 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -52,7 +52,7 @@ function entity_info_cache_clear() { function entity_render_cache_clear() { $entity_manager = Drupal::entityManager(); foreach ($entity_manager->getDefinitions() as $entity_type => $info) { - if ($entity_manager->hasController($entity_type, 'render')) { + if ($entity_manager->hasController($entity_type, 'view_builder')) { $entity_manager->getViewBuilder($entity_type)->resetCache(); } } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index ff3ea8a..6b1a788 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -365,7 +365,7 @@ public function changed() { } foreach ($referenced_entity_ids as $entity_type => $entity_ids) { - if (\Drupal::entityManager()->hasController($entity_type, 'render')) { + if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) { \Drupal::entityManager()->getViewBuilder($entity_type)->resetCache(array_keys($entity_ids)); } } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index fb77b45..7732895 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -297,7 +297,7 @@ function comment_field_instance_create(FieldInstanceInterface $instance) { */ function comment_field_instance_update(FieldInstanceInterface $instance) { if ($instance->getFieldType() == 'comment') { - \Drupal::entityManager()->getRenderController($instance->entity_type)->resetCache(); + \Drupal::entityManager()->getViewBuilder($instance->entity_type)->resetCache(); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index ecbe5b2..48e420b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -49,7 +49,7 @@ public static function create(ContainerInterface $container) { } /** - * Constructs a new CommentRenderController. + * Constructs a new CommentFormController. * * @param \Drupal\Core\Entity\EntityManager $entity_manager * The entity manager service. @@ -410,6 +410,6 @@ public function save(array $form, array &$form_state) { // Clear the block and page caches so that anonymous users see the comment // they have posted. Cache::invalidateTags(array('content' => TRUE)); - $this->entityManager->getRenderController($entity->entityType())->resetCache(array($entity->id())); + $this->entityManager->getViewBuilder($entity->entityType())->resetCache(array($entity->id())); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 9a8260e..b4b3065 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -20,7 +20,7 @@ /** * Render controller for comments. */ -class CommentViewBuilder extends EntityViewBuilder implements EntityViewBuilderInterface { +class CommentViewBuilder extends EntityViewBuilder implements EntityViewBuilderInterface, EntityControllerInterface { /** * The entity manager service. @@ -56,7 +56,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ } /** - * Constructs a new CommentRenderController. + * Constructs a new CommentViewBuilder. * * @param string $entity_type * The entity type. @@ -75,7 +75,7 @@ public function __construct($entity_type, EntityManager $entity_manager, FieldIn } /** - * Overrides Drupal\Core\Entity\EntityRenderController::buildContent(). + * Overrides Drupal\Core\Entity\EntityViewBuilder::buildContent(). * * In addition to modifying the content key on entities, this implementation * will also set the comment entity key which all comments carry. diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php index 5ae427f..0c8c229 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Plugin\field\formatter; use Drupal\comment\CommentStorageControllerInterface; -use Drupal\Core\Entity\EntityRenderControllerInterface; +use Drupal\Core\Entity\EntityViewBuilderInterface; use Drupal\Core\Entity\Field\FieldItemListInterface; use Drupal\Core\Session\AccountInterface; use Drupal\field\Annotation\FieldFormatter; @@ -49,9 +49,9 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP /** * The comment render controller. * - * @var \Drupal\Core\Entity\EntityRenderControllerInterface + * @var \Drupal\Core\Entity\EntityViewBuilderInterface */ - protected $renderController; + protected $viewBuilder; /** * {@inheritdoc} @@ -66,7 +66,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration['view_mode'], $container->get('current_user'), $container->get('entity.manager')->getStorageController('comment'), - $container->get('entity.manager')->getRenderController('comment') + $container->get('entity.manager')->getViewBuilder('comment') ); } @@ -89,12 +89,12 @@ public static function create(ContainerInterface $container, array $configuratio * The current user. * @param \Drupal\comment\CommentStorageControllerInterface * The comment storage controller. - * @param \Drupal\Core\Entity\EntityRenderControllerInterface - * The comment render controller. + * @param \Drupal\Core\Entity\EntityViewBuilderInterface + * The comment view builder. */ - public function __construct($plugin_id, array $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, AccountInterface $current_user, CommentStorageControllerInterface $comment_storage_controller, EntityRenderControllerInterface $comment_render_controller) { + public function __construct($plugin_id, array $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, AccountInterface $current_user, CommentStorageControllerInterface $comment_storage_controller, EntityViewBuilderInterface $comment_view_builder) { parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode); - $this->renderController = $comment_render_controller; + $this->viewBuilder = $comment_view_builder; $this->storageController = $comment_storage_controller; $this->currentUser = $current_user; } @@ -129,7 +129,7 @@ public function viewElements(FieldItemListInterface $items) { if ($cids = comment_get_thread($entity, $field_name, $mode, $comments_per_page)) { $comments = $this->storageController->loadMultiple($cids); comment_prepare_thread($comments); - $build = $this->renderController->viewMultiple($comments); + $build = $this->viewBuilder->viewMultiple($comments); $build['pager']['#theme'] = 'pager'; $output['comments'] = $build; } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index 7ec721f..a4ed5f1 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -307,7 +307,7 @@ function testCommentFunctionality() { )); // We've changed role permissions, so need to reset render cache. // @todo Revisit after https://drupal.org/node/2099105 - \Drupal::entityManager()->getRenderController('entity_test')->resetCache(array($this->entity->id())); + \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($this->entity->id())); $this->drupalGet('entity-test/' . $this->entity->id()); $this->assertPattern('@]*>Comments@', 'Comments were displayed.'); $this->assertLink('Log in', 0, 'Link to log in was found.'); @@ -326,7 +326,7 @@ function testCommentFunctionality() { )); // We've changed role permissions, so need to reset render cache. // @todo Revisit after https://drupal.org/node/2099105 - \Drupal::entityManager()->getRenderController('entity_test')->resetCache(array($this->entity->id())); + \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($this->entity->id())); $this->drupalGet('entity-test/' . $this->entity->id()); $this->assertNoPattern('@]*>Comments@', 'Comments were not displayed.'); $this->assertFieldByName('subject', '', 'Subject field found.'); diff --git a/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php b/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php index 153c547..da7b936 100644 --- a/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php +++ b/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php @@ -52,7 +52,7 @@ public function viewModeTypeSelection() { drupal_set_title(t('Choose view mode entity type')); $entity_types = array(); foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { - if ($entity_info['fieldable'] && isset($entity_info['controllers']['render'])) { + if ($entity_info['fieldable'] && isset($entity_info['controllers']['view_builder'])) { $entity_types[$entity_type] = array( 'title' => $entity_info['label'], 'href' => 'admin/structure/display-modes/view/add/' . $entity_type, diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 3fb46a6..0278c58 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -133,7 +133,7 @@ public function save() { $return = parent::save(); // Reset the render cache for the target entity type. - if (\Drupal::entityManager()->hasController($this->targetEntityType, 'render')) { + if (\Drupal::entityManager()->hasController($this->targetEntityType, 'view_builder')) { \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php index 6bc6bd8..835c1c6 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php @@ -146,7 +146,7 @@ public function render() { * doesn't has the correct controller. */ protected function isValidEntity($entity_type) { - return isset($this->entityInfoComplete[$entity_type]['controllers']['render']); + return isset($this->entityInfoComplete[$entity_type]['controllers']['view_builder']); } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php index 6eb2d2f..a3167c5 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php @@ -41,7 +41,7 @@ public function validate(array $form, array &$form_state) { */ protected function prepareEntity() { $definition = $this->entityManager->getDefinition($this->entityType); - if (!$definition['fieldable'] || !isset($definition['controllers']['render'])) { + if (!$definition['fieldable'] || !isset($definition['controllers']['view_builder'])) { throw new NotFoundHttpException(); } diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php index 9868ca2..803fbe3 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php @@ -40,14 +40,14 @@ public function testEntityViewModeUI() { $this->drupalGet('admin/structure/display-modes/view'); $this->assertResponse(200); - $this->drupalGet('admin/structure/display-modes/view/add/entity_test'); + $this->drupalGet('admin/structure/display-modes/view/add/entity_test_mul'); $this->assertResponse(404); $this->drupalGet('admin/structure/display-modes/view/add'); - $this->assertNoLink(t('Test entity'), 'An entity type with no view builder cannot have view modes.'); + $this->assertNoLink(t('Test entity - data table'), 'An entity type with no view builder cannot have view modes.'); // Test adding a view mode. - $this->clickLink(t('Test render entity')); + $this->clickLink(t('Test entity')); $edit = array( 'id' => strtolower($this->randomName()), 'label' => $this->randomString(), @@ -76,7 +76,7 @@ public function testEntityFormModeUI() { $this->drupalGet('admin/structure/display-modes/form'); $this->assertResponse(200); - $this->drupalGet('admin/structure/display-modes/form/add/entity_test'); + $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label'); $this->assertResponse(404); $this->drupalGet('admin/structure/display-modes/form/add'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php index ccc0588..842668b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php @@ -34,7 +34,7 @@ public function testMethods() { $this->assertFalse($entity_manager->hasController('non_existent', 'non_existent'), 'A non existent entity type has no controller.'); $this->assertFalse($entity_manager->hasController('entity_test', 'non_existent'), 'An existent entity type does not have a non existent controller.'); - $this->assertFalse($entity_manager->hasController('entity_test', 'render'), 'The test entity does not have specified the view builder.'); + $this->assertFalse($entity_manager->hasController('entity_test_mul', 'view_builder'), 'The test entity does not have specified the view builder.'); $this->assertTrue($entity_manager->hasController('entity_test', 'storage'), 'The test entity has specified the controller class'); } diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php index 3f17087..5116c70 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -53,7 +53,7 @@ public function testEntityAreaData() { $entity_info = $this->container->get('entity.manager')->getDefinitions(); $expected_entities = array_filter($entity_info, function($info) { - return !empty($info['controllers']['render']); + return !empty($info['controllers']['view_builder']); }); // Test that all expected entity types have data. @@ -64,7 +64,7 @@ public function testEntityAreaData() { } $expected_entities = array_filter($entity_info, function($info) { - return empty($info['controllers']['render']); + return empty($info['controllers']['view_builder']); }); // Test that no configuration entity types have data. diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 9b49b92..b3af1d4 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -117,7 +117,7 @@ function views_views_data() { // Registers an entity area handler per entity type. foreach (entity_get_info() as $entity_type => $entity_info) { // Exclude entity types, which cannot be rendered. - if (!empty($entity_info['controllers']['render'])) { + if (!empty($entity_info['controllers']['view_builder'])) { $label = $entity_info['label']; $data['views']['entity_' . $entity_type] = array( 'title' => t('Rendered entity - @label', array('@label' => $label)),