class CacheableMetadataCalculationTest
Same name in this branch
- 10 core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest
- 9 core/modules/views/tests/modules/views_test_cacheable_metadata_calculation/src/Plugin/views/access/CacheableMetadataCalculationTest.php \Drupal\views_test_cacheable_metadata_calculation\Plugin\views\access\CacheableMetadataCalculationTest
- 8.9.x core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest
- 8.9.x core/modules/views/tests/modules/views_test_cacheable_metadata_calculation/src/Plugin/views/access/CacheableMetadataCalculationTest.php \Drupal\views_test_cacheable_metadata_calculation\Plugin\views\access\CacheableMetadataCalculationTest
- 11.x core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest
- 11.x core/modules/views/tests/modules/views_test_cacheable_metadata_calculation/src/Plugin/views/access/CacheableMetadataCalculationTest.php \Drupal\views_test_cacheable_metadata_calculation\Plugin\views\access\CacheableMetadataCalculationTest
Tests plugin that reports when cacheable metadata is being calculated.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface
- class \Drupal\views\Plugin\views\access\AccessPluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views_test_cacheable_metadata_calculation\Plugin\views\access\CacheableMetadataCalculationTest extends \Drupal\views\Plugin\views\access\AccessPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface
- class \Drupal\views\Plugin\views\access\AccessPluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of CacheableMetadataCalculationTest
File
-
core/
modules/ views/ tests/ modules/ views_test_cacheable_metadata_calculation/ src/ Plugin/ views/ access/ CacheableMetadataCalculationTest.php, line 18
Namespace
Drupal\views_test_cacheable_metadata_calculation\Plugin\views\accessView source
class CacheableMetadataCalculationTest extends AccessPluginBase implements CacheableDependencyInterface {
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a CacheableMetadataCalculationTest access plugin.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('state'));
}
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function alterRouteDefinition(Route $route) {
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
$this->cacheableMetadataHasBeenAccessed();
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
$this->cacheableMetadataHasBeenAccessed();
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
$this->cacheableMetadataHasBeenAccessed();
return Cache::PERMANENT;
}
/**
* Sets a flag to inform tests that cacheable metadata has been accessed.
*/
protected function cacheableMetadataHasBeenAccessed() {
$this->state
->set('views_test_cacheable_metadata_has_been_accessed', TRUE);
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.