diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Tag.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Tag.php index b7bb290..4cad30b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Tag.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Tag.php @@ -7,6 +7,31 @@ namespace Drupal\views\Plugin\views\cache; -class Tag { +/** + * Simple caching of query results for Views displays. + * + * @ingroup views_cache_plugins + * + * @ViewsCache( + * id = "tag", + * title = @Translation("Tag based"), + * help = @Translation("Tag based caching of data. Caches will persist until any related cache tags are invalidated.") + * ) + */ +class Tag extends CachePluginBase { + + /** + * {@inheritdoc} + */ + public function summaryTitle() { + return t('Tag'); + } + + /** + * {@inheritdoc} + */ + protected function cacheExpire($type) { + return FALSE; + } } diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index 54ac900..b85f3e3 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -2,11 +2,12 @@ /** * @file - * Contains \Drupal\views\Tests\ViewExecutableUnitTest. + * Contains \Drupal\views\Tests\ViewExecutableTest. */ namespace Drupal\views\Tests; +use Drupal\views\Views; use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutableFactory; use Drupal\views\DisplayBag; @@ -35,7 +36,7 @@ class ViewExecutableTest extends ViewUnitTestBase { * * @var array */ - public static $testViews = array('test_destroy', 'test_executable_displays'); + public static $testViews = array('test_destroy', 'test_executable_displays', 'test_view'); /** * Properties that should be stored in the configuration. @@ -433,4 +434,16 @@ public function testValidate() { $this->assertNotIdentical($validate, $validate_deleted, 'Master display has not been validated.'); } + /** + * Tests the getEntityTypes() method. + */ + public function testGetEntityTypes() { + // Test a view that should return no entity types. + $view = Views::getView('test_view'); + $this->assertIdentical($view->getEntityTypes(), array(), 'No entity types were returned.'); + // The base entity type (node) and relationships should be returned. + $view = Views::getView('test_destroy'); + $this->assertIdentical($view->getEntityTypes(), array('node', 'comment', 'user'), 'The expected entity types were returned.'); + } + } diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index 5d9cd95..45cffaf 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -2252,7 +2252,7 @@ public function getEntityTypes() { } } - return array_unique($entity_types); + return array_values(array_unique($entity_types)); } }