/** * Returns the valid types of plugins that can be used. * * @return array * An array of plugin type strings. */ public static function getPluginTypes($type = NULL) { return Views::getPluginTypes($type); }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); // Ensure that the view is dependant on the module that implements the view. $this->addDependency('module', $this->module); // Ensure that the view is dependent on the module that provides the schema // for the base table. $schema = $this->drupalGetSchema($this->base_table); // @todo Entity base tables are no longer registered in hook_schema(). Once // we automate the views data for entity types add the entity type // type provider as a dependency. See https://drupal.org/node/1740492. if ($schema && $this->module != $schema['module']) { $this->addDependency('module', $schema['module']); } $handler_types = array(); foreach (Views::getHandlerTypes() as $type) { $handler_types[] = $type['plural']; } foreach ($this->get('display') as $display) { // Collect all dependencies of all handlers. foreach ($handler_types as $handler_type) { if (!empty($display['display_options'][$handler_type])) { foreach ($display['display_options'][$handler_type] as $handler) { // Add the provider as dependency. if (isset($handler['provider'])) { $this->addDependency('module', $handler['provider']); } // Add the additional dependencies from the handler configuration. if (!empty($handler['dependencies'])) { $this->addDependencies($handler['dependencies']); } } } } // Collect all dependencies of plugins. foreach (Views::getPluginTypes('plugin') as $plugin_type) { if (!empty($display['display_options'][$plugin_type]['options']['dependencies'])) { $this->addDependencies($display['display_options'][$plugin_type]['options']['dependencies']); } } } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateCacheMetadata() { $cache_metadata = new CacheableMetadata(); // Iterate over ordinary views plugins. foreach (Views::getPluginTypes('plugin') as $plugin_type) { $plugin = $this->getPlugin($plugin_type); if ($plugin instanceof CacheableDependencyInterface) { $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($plugin)); } } // Iterate over all handlers. Note that at least the argument handler will // need to ask all its subplugins. foreach (array_keys(Views::getHandlerTypes()) as $handler_type) { $handlers = $this->getHandlers($handler_type); foreach ($handlers as $handler) { if ($handler instanceof CacheableDependencyInterface) { $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($handler)); } } } /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */ if ($cache_plugin = $this->getPlugin('cache')) { $cache_plugin->alterCacheMetadata($cache_metadata); } return $cache_metadata; }
/** * {@inheritdoc} */ public function calculateCacheMetadata() { $is_cacheable = TRUE; $cache_contexts = []; // Iterate over ordinary views plugins. foreach (Views::getPluginTypes('plugin') as $plugin_type) { $plugin = $this->getPlugin($plugin_type); if ($plugin instanceof CacheablePluginInterface) { $cache_contexts = array_merge($cache_contexts, $plugin->getCacheContexts()); $is_cacheable &= $plugin->isCacheable(); } else { $is_cacheable = FALSE; } } // Iterate over all handlers. Note that at least the argument handler will // need to ask all its subplugins. foreach (array_keys(Views::getHandlerTypes()) as $handler_type) { $handlers = $this->getHandlers($handler_type); foreach ($handlers as $handler) { if ($handler instanceof CacheablePluginInterface) { $cache_contexts = array_merge($cache_contexts, $handler->getCacheContexts()); $is_cacheable &= $handler->isCacheable(); } } } /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */ if ($cache_plugin = $this->getPlugin('cache')) { $cache_plugin->alterCacheMetadata($is_cacheable, $cache_contexts); } return [(bool) $is_cacheable, $cache_contexts]; }