Commit 4b7bbecb authored by alexpott's avatar alexpott

Issue #2097903 by Berdir, amateescu: Rename EntityRenderController to EntityViewBuilder.

parent e01957ff
......@@ -52,8 +52,8 @@ 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')) {
$entity_manager->getRenderController($entity_type)->resetCache();
if ($entity_manager->hasController($entity_type, 'view_builder')) {
$entity_manager->getViewBuilder($entity_type)->resetCache();
}
}
}
......@@ -435,7 +435,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
* @return \Drupal\Core\Entity\EntityAccessControllerInterface
* An entity access controller instance.
*
* @deprecated Use \Drupal\Core\Entity\EntityManager::getRenderController().
* @deprecated Use \Drupal\Core\Entity\EntityManager::getAccessController().
*/
function entity_access_controller($entity_type) {
return \Drupal::entityManager()
......@@ -551,22 +551,6 @@ function entity_list_controller($entity_type) {
->getListController($entity_type);
}
/**
* Returns an entity render controller for a given entity type.
*
* @param string $entity_type
* The type of the entity.
*
* @return \Drupal\Core\Entity\EntityRenderControllerInterface
* An entity render controller.
*
* @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController().
*/
function entity_render_controller($entity_type) {
return \Drupal::entityManager()
->getRenderController($entity_type);
}
/**
* Returns the render array for an entity.
*
......@@ -585,7 +569,7 @@ function entity_render_controller($entity_type) {
* A render array for the entity.
*/
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
$render_controller = \Drupal::entityManager()->getRenderController($entity->entityType());
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->entityType());
if ($reset) {
$render_controller->resetCache(array($entity->id()));
}
......@@ -611,7 +595,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
* entities array passed in $entities.
*/
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
$render_controller = \Drupal::entityManager()->getRenderController(reset($entities)->entityType());
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->entityType());
if ($reset) {
$render_controller->resetCache(array_keys($entities));
}
......
......@@ -57,7 +57,7 @@ class EntityType extends Plugin {
* - list: The name of the class that provides listings of the entities. The
* class must implement \Drupal\Core\Entity\EntityListControllerInterface.
* - render: The name of the class that is used to render the entities. The
* class must implement \Drupal\Core\Entity\EntityRenderControllerInterface.
* class must implement \Drupal\Core\Entity\EntityViewBuilderInterface.
* - access: The name of the class that is used for access checks. The class
* must implement \Drupal\Core\Entity\EntityAccessControllerInterface.
* Defaults to \Drupal\Core\Entity\EntityAccessController.
......
......@@ -62,7 +62,7 @@ public static function create(ContainerInterface $container) {
*/
public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) {
return $this->entityManager
->getRenderController($_entity->entityType())
->getViewBuilder($_entity->entityType())
->view($_entity, $view_mode, $langcode);
}
......
......@@ -364,8 +364,8 @@ public function changed() {
}
foreach ($referenced_entity_ids as $entity_type => $entity_ids) {
if (\Drupal::entityManager()->hasController($entity_type, 'render')) {
\Drupal::entityManager()->getRenderController($entity_type)->resetCache(array_keys($entity_ids));
if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) {
\Drupal::entityManager()->getViewBuilder($entity_type)->resetCache(array_keys($entity_ids));
}
}
}
......
......@@ -307,16 +307,16 @@ public function getFormController($entity_type, $operation) {
}
/**
* Creates a new render controller instance.
* Creates a new view builder instance.
*
* @param string $entity_type
* The entity type for this render controller.
* The entity type for this view builder.
*
* @return \Drupal\Core\Entity\EntityRenderControllerInterface.
* A render controller instance.
* @return \Drupal\Core\Entity\EntityViewBuilderInterface.
* A view builder instance.
*/
public function getRenderController($entity_type) {
return $this->getController($entity_type, 'render');
public function getViewBuilder($entity_type) {
return $this->getController($entity_type, 'view_builder');
}
/**
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Core\Entity\EntityRenderController.
* Contains \Drupal\Core\Entity\EntityViewBuilder.
*/
namespace Drupal\Core\Entity;
......@@ -13,7 +13,7 @@
/**
* Base class for entity view controllers.
*/
class EntityRenderController implements EntityRenderControllerInterface {
class EntityViewBuilder implements EntityViewBuilderInterface {
/**
* The type of entities for which this controller is instantiated.
......@@ -56,7 +56,7 @@ public function __construct($entity_type) {
}
/**
* Implements \Drupal\Core\Entity\EntityRenderControllerInterface::buildContent().
* {@inheritdoc}
*/
public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) {
field_attach_prepare_view($this->entityType, $entities, $displays, $langcode);
......@@ -148,7 +148,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { }
/**
* Implements \Drupal\Core\Entity\EntityRenderControllerInterface::view().
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
$buildList = $this->viewMultiple(array($entity), $view_mode, $langcode);
......@@ -156,7 +156,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
}
/**
* Implements \Drupal\Core\Entity\EntityRenderControllerInterface::viewMultiple().
* {@inheritdoc}
*/
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Core\Entity\EntityRenderControllerInterface.
* Contains \Drupal\Core\Entity\EntityViewBuilderInterface.
*/
namespace Drupal\Core\Entity;
......@@ -10,7 +10,7 @@
/**
* Defines a common interface for entity view controller classes.
*/
interface EntityRenderControllerInterface {
interface EntityViewBuilderInterface {
/**
* Build the structured $content property on the entity.
......
......@@ -85,7 +85,7 @@ public function feedAdd() {
*/
public function viewFeed(FeedInterface $aggregator_feed) {
$entity_manager = $this->entityManager();
$feed_source = $entity_manager->getRenderController('aggregator_feed')
$feed_source = $entity_manager->getViewBuilder('aggregator_feed')
->view($aggregator_feed, 'default');
// Load aggregator feed item for the particular feed id.
$items = $entity_manager->getStorageController('aggregator_item')->loadByFeed($aggregator_feed->id());
......@@ -131,7 +131,7 @@ protected function buildPageList(array $items, $feed_source = '') {
);
$build['feed_source'] = is_array($feed_source) ? $feed_source : array('#markup' => $feed_source);
if ($items) {
$build['items'] = $this->entityManager()->getRenderController('aggregator_item')
$build['items'] = $this->entityManager()->getViewBuilder('aggregator_item')
->viewMultiple($items, 'default');
$build['pager'] = array('#theme' => 'pager');
}
......@@ -274,7 +274,7 @@ public function categories() {
if ($aggregator_summary_items) {
$items = $entity_manager->getStorageController('aggregator_item')->loadByCategory($category->cid);
if ($items) {
$summary_items = $entity_manager->getRenderController('aggregator_item')->viewMultiple($items, 'summary');
$summary_items = $entity_manager->getViewBuilder('aggregator_item')->viewMultiple($items, 'summary');
}
}
$category->url = $this->urlGenerator()->generateFromPath('aggregator/categories/' . $category->cid);
......@@ -326,7 +326,7 @@ public function sources() {
$items = $entity_manager->getStorageController('aggregator_item')
->loadByFeed($feed->id());
if ($items) {
$summary_items = $entity_manager->getRenderController('aggregator_item')
$summary_items = $entity_manager->getViewBuilder('aggregator_item')
->viewMultiple($items, 'summary');
}
}
......
......@@ -23,7 +23,7 @@
* module = "aggregator",
* controllers = {
* "storage" = "Drupal\aggregator\FeedStorageController",
* "render" = "Drupal\aggregator\FeedRenderController",
* "view_builder" = "Drupal\aggregator\FeedViewBuilder",
* "form" = {
* "default" = "Drupal\aggregator\FeedFormController",
* "delete" = "Drupal\aggregator\Form\FeedDeleteForm",
......
......@@ -22,7 +22,7 @@
* module = "aggregator",
* controllers = {
* "storage" = "Drupal\aggregator\ItemStorageController",
* "render" = "Drupal\aggregator\ItemRenderController"
* "view_builder" = "Drupal\aggregator\ItemViewBuilder"
* },
* base_table = "aggregator_item",
* fieldable = TRUE,
......
......@@ -2,21 +2,21 @@
/**
* @file
* Contains \Drupal\aggregator\FeedRenderController.
* Contains \Drupal\aggregator\FeedViewBuilder.
*/
namespace Drupal\aggregator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRenderController;
use Drupal\Core\Entity\EntityViewBuilder;
/**
* Render controller for aggregator feed items.
*/
class FeedRenderController extends EntityRenderController {
class FeedViewBuilder extends EntityViewBuilder {
/**
* Overrides Drupal\Core\Entity\EntityRenderController::getBuildDefaults().
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$defaults = parent::getBuildDefaults($entity, $view_mode, $langcode);
......
......@@ -11,7 +11,7 @@
use Drupal\aggregator\FeedInterface;
use Drupal\aggregator\ItemStorageControllerInterface;
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\EntityRenderControllerInterface;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Form\FormBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -21,9 +21,9 @@
abstract class AggregatorCategorizeFormBase extends FormBase {
/**
* The aggregator item render controller.
* The aggregator item view builder.
*
* @var \Drupal\Core\Entity\EntityRenderControllerInterface
* @var \Drupal\Core\Entity\EntityViewBuilderInterface
*/
protected $aggregatorItemRenderer;
......@@ -58,26 +58,23 @@ abstract class AggregatorCategorizeFormBase extends FormBase {
/**
* Constructs a \Drupal\aggregator\Controller\AggregatorController object.
*
* @param \Drupal\Core\Entity\EntityRenderControllerInterface $aggregator_item_renderer
* The item render controller.
* @param \Drupal\Core\Entity\EntityViewBuilderInterface $aggregator_item_renderer
* The item view builder.
* @param \Drupal\aggregator\ItemStorageControllerInterface $aggregator_item_storage
* The aggregator item storage controller.
* @param \Drupal\aggregator\CategoryStorageControllerInterface $category_storage
* The category storage controller.
*/
public function __construct(EntityRenderControllerInterface $aggregator_item_renderer, ItemStorageControllerInterface $aggregator_item_storage, CategoryStorageControllerInterface $category_storage) {
public function __construct(EntityViewBuilderInterface $aggregator_item_renderer, ItemStorageControllerInterface $aggregator_item_storage, CategoryStorageControllerInterface $category_storage) {
$this->aggregatorItemRenderer = $aggregator_item_renderer;
$this->config = $this->config('aggregator.settings');
$this->aggregatorItemStorage = $aggregator_item_storage;
$this->categoryStorage = $category_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('plugin.manager.entity')->getRenderController('aggregator_item'),
$container->get('plugin.manager.entity')->getViewBuilder('aggregator_item'),
$container->get('plugin.manager.entity')->getStorageController('aggregator_item'),
$container->get('aggregator.category.storage')
);
......
......@@ -2,21 +2,21 @@
/**
* @file
* Contains \Drupal\aggregator\ItemRenderController.
* Contains \Drupal\aggregator\ItemViewBuilder.
*/
namespace Drupal\aggregator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRenderController;
use Drupal\Core\Entity\EntityViewBuilder;
/**
* Render controller for aggregator feed items.
*/
class ItemRenderController extends EntityRenderController {
class ItemViewBuilder extends EntityViewBuilder {
/**
* Overrides Drupal\Core\Entity\EntityRenderController::getBuildDefaults().
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$defaults = parent::getBuildDefaults($entity, $view_mode, $langcode);
......
......@@ -143,7 +143,7 @@ public function process(Feed $feed) {
return;
}
foreach ($feed->items as $item) {
// @todo: The default entity render controller always returns an empty
// @todo: The default entity view builder always returns an empty
// array, which is ignored in aggregator_save_item() currently. Should
// probably be fixed.
if (empty($item['title'])) {
......
......@@ -2,22 +2,22 @@
/**
* @file
* Contains \Drupal\custom_block\CustomBlockRenderController.
* Contains \Drupal\custom_block\CustomBlockViewBuilder.
*/
namespace Drupal\custom_block;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRenderController;
use Drupal\Core\Entity\EntityViewBuilder;
use Drupal\entity\Entity\EntityDisplay;
/**
* Render controller for custom blocks.
*/
class CustomBlockRenderController extends EntityRenderController {
class CustomBlockViewBuilder extends EntityViewBuilder {
/**
* Overrides \Drupal\Core\Entity\EntityRenderController::alterBuild().
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
......
......@@ -25,7 +25,7 @@
* "storage" = "Drupal\custom_block\CustomBlockStorageController",
* "access" = "Drupal\custom_block\CustomBlockAccessController",
* "list" = "Drupal\custom_block\CustomBlockListController",
* "render" = "Drupal\custom_block\CustomBlockRenderController",
* "view_builder" = "Drupal\custom_block\CustomBlockViewBuilder",
* "form" = {
* "add" = "Drupal\custom_block\CustomBlockFormController",
* "edit" = "Drupal\custom_block\CustomBlockFormController",
......
......@@ -44,7 +44,7 @@ public function access(AccountInterface $account);
* @return array
* A renderable array representing the content of the block.
*
* @see \Drupal\block\BlockRenderController
* @see \Drupal\block\BlockViewBuilder
*/
public function build();
......
......@@ -2,28 +2,28 @@
/**
* @file
* Contains \Drupal\block\BlockRenderController.
* Contains \Drupal\block\BlockViewBuilder.
*/
namespace Drupal\block;
use Drupal\Core\Entity\EntityRenderControllerInterface;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a Block render controller.
* Provides a Block view builder.
*/
class BlockRenderController implements EntityRenderControllerInterface {
class BlockViewBuilder implements EntityViewBuilderInterface {
/**
* Implements \Drupal\Core\Entity\EntityRenderControllerInterface::buildContent().
* {@inheritdoc}
*/
public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) {
return array();
}
/**
* Implements Drupal\Core\Entity\EntityRenderControllerInterface::view().
* {@inheritdoc}
*/
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
$build = $this->viewMultiple(array($entity), $view_mode, $langcode);
......@@ -31,7 +31,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
}
/**
* Implements Drupal\Core\Entity\EntityRenderControllerInterface::viewMultiple().
* {@inheritdoc}
*/
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
$build = array();
......
......@@ -24,7 +24,7 @@
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "access" = "Drupal\block\BlockAccessController",
* "render" = "Drupal\block\BlockRenderController",
* "view_builder" = "Drupal\block\BlockViewBuilder",
* "list" = "Drupal\block\BlockListController",
* "form" = {
* "default" = "Drupal\block\BlockFormController",
......
......@@ -26,11 +26,11 @@ class BookExport {
protected $nodeStorage;
/**
* The node render controller.
* The node view builder.
*
* @var \Drupal\Core\Entity\EntityRenderControllerInterface
* @var \Drupal\Core\Entity\EntityViewBuilderInterface
*/
protected $nodeRender;
protected $viewBuilder;
/**
* Constructs a BookExport object.
......@@ -40,7 +40,7 @@ class BookExport {
*/
public function __construct(EntityManager $entityManager) {
$this->nodeStorage = $entityManager->getStorageController('node');
$this->nodeRender = $entityManager->getRenderController('node');
$this->viewBuilder = $entityManager->getViewBuilder('node');
}
/**
......@@ -125,7 +125,7 @@ protected function exportTraverse(array $tree, $callable) {
* @see \Drupal\book\BookExport::exportTraverse()
*/
protected function bookNodeExport(NodeInterface $node, $children = '') {
$build = $this->nodeRender->view($node, 'print', NULL);
$build = $this->viewBuilder->view($node, 'print', NULL);
unset($build['#theme']);
// @todo Rendering should happen in the template using render().
......
......@@ -271,7 +271,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();
}
}
......@@ -1255,7 +1255,7 @@ function comment_get_display_ordinal($cid, $instance) {
else {
// For threaded comments, the c.thread column is used for ordering. We can
// use the sorting code for comparison, but must remove the trailing slash.
// See CommentRenderController.
// See CommentViewBuilder.
$query->where('SUBSTRING(c1.thread, 1, (LENGTH(c1.thread) -1)) < SUBSTRING(c2.thread, 1, (LENGTH(c2.thread) -1))');
}
......@@ -1372,7 +1372,7 @@ function comment_preprocess_block(&$variables) {
* A user account, for use with theme_username() or the user_picture template.
*/
function comment_prepare_author(CommentInterface $comment) {
// The account has been pre-loaded by CommentRenderController::buildContent().
// The account has been pre-loaded by CommentViewBuilder::buildContent().
$account = $comment->uid->entity;
if (empty($account->uid->value)) {
$account = entity_create('user', array('uid' => 0, 'name' => $comment->name->value, 'homepage' => $comment->homepage->value));
......
......@@ -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()));
}
}
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\comment\CommentRenderController.
* Definition of Drupal\comment\CommentViewBuilder.
*/
namespace Drupal\comment;
......@@ -11,8 +11,9 @@
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityRenderController;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Entity\EntityViewBuilder;
use Drupal\entity\Entity\EntityDisplay;
use Drupal\field\FieldInfo;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -20,7 +21,7 @@
/**
* Render controller for comments.
*/
class CommentRenderController extends EntityRenderController implements EntityControllerInterface {
class CommentViewBuilder extends EntityViewBuilder implements EntityViewBuilderInterface, EntityControllerInterface {
/**
* The entity manager service.
......@@ -64,7 +65,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ
}
/**
* Constructs a new CommentRenderController.
* Constructs a new CommentViewBuilder.
*
* @param string $entity_type
* The entity type.
......@@ -86,7 +87,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.
......@@ -225,7 +226,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
}
/**
* Overrides Drupal\Core\Entity\EntityRenderController::alterBuild().
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $comment, EntityDisplay $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $comment, $display, $view_mode, $langcode);
......
......@@ -275,7 +275,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_
return new RedirectResponse($this->urlGenerator()->generateFromPath($uri['path'], array('absolute' => TRUE)));
}
// Display the parent comment.
$build['comment_parent'] = $this->entityManager()->getRenderController('comment')->view($comment);
$build['comment_parent'] = $this->entityManager()->getViewBuilder('comment')->view($comment);
}
// The comment is in response to a entity.
......@@ -284,7 +284,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_
// redirect loop.
$entity->{$field_name}->status = COMMENT_HIDDEN;
// Render array of the entity full view mode.
$build['commented_entity'] = $this->entityManager()->getRenderController($entity->entityType())->view($entity, 'full');
$build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->entityType())->view($entity, 'full');
unset($build['commented_entity']['#cache']);
$entity->{$field_name}->status = $status;
}
......
......@@ -25,7 +25,7 @@
* controllers = {
* "storage" = "Drupal\comment\CommentStorageController",
* "access" = "Drupal\comment\CommentAccessController",
* "render" = "Drupal\comment\CommentRenderController",
* "view_builder" = "Drupal\comment\CommentViewBuilder",
* "form" = {
* "default" = "Drupal\comment\CommentFormController",
* "delete" = "Drupal\comment\Form\DeleteForm"
......
......@@ -8,7 +8,7 @@
namespace Drupal\comment\Plugin\Field\FieldFormatter;
use Drupal\comment\CommentStorageControllerInterface;
use Drupal\Core\Entity\EntityRenderControllerInterface;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
......@@ -47,9 +47,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}
......@@ -64,7 +64,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')
);
}
......@@ -87,12 +87,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;
}
......@@ -127,7 +127,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;
}
......
......@@ -12,7 +12,7 @@
use Drupal\Core\Entity\EntityInterface;
/**
* Tests basic comment functionality against the entity_test_render entity type.
* Tests basic comment functionality against the entity_test entity type.
*/
class CommentNonNodeTest extends WebTestBase {
......@@ -36,10 +36,10 @@ public static function getInfo() {
function setUp() {
parent::setUp();
// Create a bundle for entity_test_render.
entity_test_create_bundle('entity_test_render', 'Entity Test Render', 'entity_test_render');
// Create comment field on entity_test_render bundle.