diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 23511a7..32c9da1 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -49,9 +49,9 @@ function entity_info_cache_clear() { * Clears the entity render cache for all entity types. */ function entity_render_cache_clear() { - $entity_manager = drupal_container()->get('plugin.manager.entity'); + $entity_manager = Drupal::entityManager(); foreach ($entity_manager->getDefinitions() as $entity_type => $info) { - if (isset($info['render_controller_class'])) { + if ($entity_manager->hasController($entity_type, 'render')) { $entity_manager->getRenderController($entity_type)->resetCache(); } } diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 7317ed8..5eeb08a 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -265,7 +265,7 @@ public function submit(array $form, array &$form_state) { public function save(array $form, array &$form_state) { // Clear the render cache. try { - \Drupal::service('plugin.manager.entity')->getRenderController($this->entity->entityType())->resetCache(array($this->entity)); + \Drupal::entityManager()->getRenderController($this->entity->entityType())->resetCache(array($this->entity)); } catch (\Exception $e) { // Nothing to do if the entity type doesn't have a render controller. diff --git a/core/modules/block/custom_block/config/entity.view_mode.custom_block.full.yml b/core/modules/block/custom_block/config/entity.view_mode.custom_block.full.yml index ebacec5..6c2a3d1 100644 --- a/core/modules/block/custom_block/config/entity.view_mode.custom_block.full.yml +++ b/core/modules/block/custom_block/config/entity.view_mode.custom_block.full.yml @@ -1,4 +1,5 @@ id: custom_block.full label: Full status: '0' +cache: '1' targetEntityType: custom_block diff --git a/core/modules/book/config/entity.view_mode.node.print.yml b/core/modules/book/config/entity.view_mode.node.print.yml index fe45f50..6f7333f 100644 --- a/core/modules/book/config/entity.view_mode.node.print.yml +++ b/core/modules/book/config/entity.view_mode.node.print.yml @@ -1,4 +1,5 @@ id: node.print label: Print status: '0' +cache: '1' targetEntityType: node diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 0025e8e..cf29b50 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -203,7 +203,7 @@ function comment_admin_overview_submit($form, &$form_state) { } drupal_set_message(t('The update has been performed.')); $form_state['redirect'] = 'admin/content/comment'; - Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::entityManager()->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); } @@ -251,7 +251,7 @@ function comment_multiple_delete_confirm($form, &$form_state) { */ function comment_multiple_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { - $entity_manager = \Drupal::service('plugin.manager.entity'); + $entity_manager = \Drupal::entityManager(); $controller = $entity_manager->getStorageController('comment'); $entities = $controller->load(array_keys($form_state['values']['comments'])); @@ -315,7 +315,7 @@ function comment_confirm_delete_submit($form, &$form_state) { drupal_set_message(t('The comment and all its replies have been deleted.')); watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $comment->id())); // Clear the cache so an anonymous user sees that his comment was deleted. - Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::entityManager()->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); $form_state['redirect'] = "node/{$comment->nid->target_id}"; diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 297799c..bf334e9 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1920,7 +1920,7 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) { */ function comment_save_action(Comment $comment) { comment_save($comment); - Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::entityManager()->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); watchdog('action', 'Saved comment %title', array('%title' => $comment->subject->value)); } diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 3e84048..371da22 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -119,7 +119,7 @@ function comment_approve(Comment $comment) { $comment->status->value = COMMENT_PUBLISHED; $comment->save(); - Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::entityManager()->getRenderController('comment')->resetCache(array($comment)); drupal_set_message(t('Comment approved.')); drupal_goto('node/' . $comment->nid->target_id); diff --git a/core/modules/comment/config/entity.view_mode.comment.full.yml b/core/modules/comment/config/entity.view_mode.comment.full.yml index e48fbd7..abfc646 100644 --- a/core/modules/comment/config/entity.view_mode.comment.full.yml +++ b/core/modules/comment/config/entity.view_mode.comment.full.yml @@ -1,4 +1,5 @@ id: comment.full label: Full comment status: '0' +cache: '1' targetEntityType: comment diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index da2ec2b..aff941d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -267,7 +267,7 @@ function setCommentsPerPage($number) { */ function setCommentSettings($name, $value, $message) { variable_set($name . '_article', $value); - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(); + \Drupal::entityManager()->getRenderController('comment')->resetCache(); // Display status message. $this->pass($message); } diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php index 8033e09..014636c 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php @@ -124,7 +124,7 @@ public function save() { // Reset the render cache for the target entity type. try { - \Drupal::service('plugin.manager.entity')->getRenderController($this->targetEntityType)->resetCache(); + \Drupal::entityManager()->getRenderController($this->targetEntityType)->resetCache(); } catch (\Exception $e) { // Nothing to do if the entity type doesn't have a render controller. diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityViewMode.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityViewMode.php index c2c54dd..a29bb82 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityViewMode.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityViewMode.php @@ -91,4 +91,11 @@ class EntityViewMode extends ConfigEntityBase implements EntityViewModeInterface */ public $status = FALSE; + /** + * Whether or not the rendered output of this view mode is cached by default. + * + * @var bool + */ + public $cache = TRUE; + } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index 66e95b3..8c56588 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -497,7 +497,7 @@ public function submitForm(array &$form, array &$form_state) { } // Clear the render cache for this entity type. - \Drupal::service('plugin.manager.entity')->getRenderController($this->entity_type)->resetCache(); + \Drupal::entityManager()->getRenderController($this->entity_type)->resetCache(); drupal_set_message(t('Your settings have been saved.')); } diff --git a/core/modules/file/config/entity.view_mode.file.full.yml b/core/modules/file/config/entity.view_mode.file.full.yml index 60808f9..4d4ed1f 100644 --- a/core/modules/file/config/entity.view_mode.file.full.yml +++ b/core/modules/file/config/entity.view_mode.file.full.yml @@ -1,4 +1,5 @@ id: file.full label: File default status: '0' +cache: '1' targetEntityType: file diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index aa3018c..6430687 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -358,5 +358,6 @@ function filter_admin_format_form_submit($form, &$form_state) { break; } + entity_render_cache_clear(); $form_state['redirect'] = 'admin/config/content/formats'; } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index ee27315..fb8e716 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -229,7 +229,7 @@ function testImageFieldDefaultImage() { $this->drupalPost("admin/structure/types/manage/article/fields/node.article.$field_name/field", $edit, t('Save field settings')); // Clear field info cache so the new default image is detected. field_info_cache_clear(); - \Drupal::service('plugin.manager.entity')->getRenderController('node')->resetCache(array($node)); + \Drupal::entityManager()->getRenderController('node')->resetCache(array($node)); $field = field_info_field($field_name); $image = file_load($field['settings']['default_image'][0]); $this->assertTrue($image->status == FILE_STATUS_PERMANENT, 'The default image status is permanent.'); diff --git a/core/modules/node/config/entity.view_mode.node.full.yml b/core/modules/node/config/entity.view_mode.node.full.yml index af6d938..e4d8bd0 100644 --- a/core/modules/node/config/entity.view_mode.node.full.yml +++ b/core/modules/node/config/entity.view_mode.node.full.yml @@ -1,4 +1,5 @@ id: node.full label: Full content status: '0' +cache: '1' targetEntityType: node diff --git a/core/modules/node/config/entity.view_mode.node.rss.yml b/core/modules/node/config/entity.view_mode.node.rss.yml index 984b05f..0dbf7c1 100644 --- a/core/modules/node/config/entity.view_mode.node.rss.yml +++ b/core/modules/node/config/entity.view_mode.node.rss.yml @@ -1,4 +1,5 @@ id: node.rss label: RSS status: '0' +cache: '1' targetEntityType: node diff --git a/core/modules/node/config/entity.view_mode.node.teaser.yml b/core/modules/node/config/entity.view_mode.node.teaser.yml index 2089b94..636de15 100644 --- a/core/modules/node/config/entity.view_mode.node.teaser.yml +++ b/core/modules/node/config/entity.view_mode.node.teaser.yml @@ -1,4 +1,5 @@ id: node.teaser label: Teaser status: '1' +cache: '1' targetEntityType: node diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 8209071..dba9816 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -139,7 +139,7 @@ function testRevisions() { $new_node_revision->setNewRevision(); $new_node_revision->isDefaultRevision = FALSE; node_save($new_node_revision); - \Drupal::service('plugin.manager.entity')->getRenderController('node')->resetCache(array($node)); + \Drupal::entityManager()->getRenderController('node')->resetCache(array($node)); $this->drupalGet("node/$node->nid"); $this->assertNoText($new_body, 'Revision body text is not present on default version of node.'); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php index 6a28f7f..7a0373c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php @@ -136,6 +136,7 @@ public function testRowPlugin() { // Test with links disabled. $view->rowPlugin->options['links'] = FALSE; + \Drupal::entityManager()->getRenderController('node')->resetCache(); $output = $view->preview(); $output = drupal_render($output); $this->drupalSetContent($output); @@ -145,6 +146,7 @@ public function testRowPlugin() { // Test with links enabled. $view->rowPlugin->options['links'] = TRUE; + \Drupal::entityManager()->getRenderController('node')->resetCache(); $output = $view->preview(); $output = drupal_render($output); $this->drupalSetContent($output); @@ -154,6 +156,7 @@ public function testRowPlugin() { // Test with comments enabled. $view->rowPlugin->options['comments'] = TRUE; + \Drupal::entityManager()->getRenderController('node')->resetCache(); $output = $view->preview(); $output = drupal_render($output); foreach ($this->nodes as $node) { @@ -164,6 +167,7 @@ public function testRowPlugin() { // Test with comments disabled. $view->rowPlugin->options['comments'] = FALSE; + \Drupal::entityManager()->getRenderController('node')->resetCache(); $output = $view->preview(); $output = drupal_render($output); foreach ($this->nodes as $node) { diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php index 23d930f..6a67605 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -285,7 +285,7 @@ function saveComment($nid, $uid, $contact = NULL, $pid = 0) { $comment = entity_create('comment', $values); $comment->save(); - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + \Drupal::entityManager()->getRenderController('comment')->resetCache(array($comment)); return $comment; } } diff --git a/core/modules/search/config/entity.view_mode.node.search_index.yml b/core/modules/search/config/entity.view_mode.node.search_index.yml index ed22c30..e12156d 100644 --- a/core/modules/search/config/entity.view_mode.node.search_index.yml +++ b/core/modules/search/config/entity.view_mode.node.search_index.yml @@ -1,4 +1,5 @@ id: node.search_index label: Search index status: '0' +cache: '1' targetEntityType: node diff --git a/core/modules/search/config/entity.view_mode.node.search_result.yml b/core/modules/search/config/entity.view_mode.node.search_result.yml index 1608657..776ada9 100644 --- a/core/modules/search/config/entity.view_mode.node.search_result.yml +++ b/core/modules/search/config/entity.view_mode.node.search_result.yml @@ -1,4 +1,5 @@ id: node.search_result label: Search result status: '0' +cache: '1' targetEntityType: node diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php index a469c75..f2afd30 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php @@ -65,7 +65,7 @@ function testTimeZoneHandling() { // Set time zone to Los Angeles time. $config->set('default', 'America/Los_Angeles')->save(); - \Drupal::service('plugin.manager.entity')->getRenderController('node')->resetCache(array($node1, $node2)); + \Drupal::entityManager()->getRenderController('node')->resetCache(array($node1, $node2)); // Confirm date format and time zone. $this->drupalGet("node/$node1->nid"); diff --git a/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.full.yml b/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.full.yml index 8902bc3..4ce40f1 100644 --- a/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.full.yml +++ b/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.full.yml @@ -1,4 +1,5 @@ id: entity_test_render.full label: Full status: '0' +cache: '1' targetEntityType: entity_test_render diff --git a/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.test.yml b/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.test.yml index a0d108b..310bceb 100644 --- a/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.test.yml +++ b/core/modules/system/tests/modules/entity_test/config/entity.view_mode.entity_test_render.test.yml @@ -1,4 +1,5 @@ id: entity_test_render.test label: Test status: '0' +cache: '1' targetEntityType: entity_test_render diff --git a/core/modules/taxonomy/config/entity.view_mode.taxonomy_term.full.yml b/core/modules/taxonomy/config/entity.view_mode.taxonomy_term.full.yml index 100547e..2666012 100644 --- a/core/modules/taxonomy/config/entity.view_mode.taxonomy_term.full.yml +++ b/core/modules/taxonomy/config/entity.view_mode.taxonomy_term.full.yml @@ -1,4 +1,5 @@ id: taxonomy_term.full label: Taxonomy term page status: '0' +cache: '1' targetEntityType: taxonomy_term diff --git a/core/modules/taxonomy/config/entity.view_mode.taxonomy_vocabulary.full.yml b/core/modules/taxonomy/config/entity.view_mode.taxonomy_vocabulary.full.yml index bb47091..8961a6f 100644 --- a/core/modules/taxonomy/config/entity.view_mode.taxonomy_vocabulary.full.yml +++ b/core/modules/taxonomy/config/entity.view_mode.taxonomy_vocabulary.full.yml @@ -1,4 +1,5 @@ id: vocabulary.full label: Taxonomy vocabulary status: '0' +cache: '1' targetEntityType: taxonomy_vocabulary diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 05e5b41..c175964 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -333,7 +333,7 @@ function testTermInterface() { // Check that it does NOT show a description when description is blank. $term->description = ''; $term->save(); - \Drupal::service('plugin.manager.entity')->getRenderController('taxonomy_term')->resetCache(array($term)); + \Drupal::entityManager()->getRenderController('taxonomy_term')->resetCache(array($term)); $this->drupalGet('taxonomy/term/' . $term->id()); $this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.'); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 2f21692..8a73c87 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -521,7 +521,7 @@ function taxonomy_term_confirm_delete_submit($form, &$form_state) { if (!isset($_GET['destination'])) { $form_state['redirect'] = 'admin/structure/taxonomy'; } - Drupal::service('plugin.manager.entity')->getRenderController('taxonomy_term')->resetCache(array($entity)); + Drupal::entityManager()->getRenderController('taxonomy_term')->resetCache(array($entity)); cache_invalidate_tags(array('content' => TRUE)); return; } diff --git a/core/modules/user/config/entity.view_mode.user.compact.yml b/core/modules/user/config/entity.view_mode.user.compact.yml index c27265b..c211e99 100644 --- a/core/modules/user/config/entity.view_mode.user.compact.yml +++ b/core/modules/user/config/entity.view_mode.user.compact.yml @@ -1,4 +1,5 @@ id: user.compact label: Compact status: '1' +cache: '1' targetEntityType: user diff --git a/core/modules/user/config/entity.view_mode.user.full.yml b/core/modules/user/config/entity.view_mode.user.full.yml index ac1ca20..343e909 100644 --- a/core/modules/user/config/entity.view_mode.user.full.yml +++ b/core/modules/user/config/entity.view_mode.user.full.yml @@ -1,4 +1,5 @@ id: user.full label: User account status: '0' +cache: '1' targetEntityType: user