You are here

MetatagViewsCachePluginManager.php in Metatag 8

File

metatag_views/src/MetatagViewsCachePluginManager.php
View source
<?php

namespace Drupal\metatag_views;

use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\Plugin\ViewsPluginManager;
class MetatagViewsCachePluginManager implements PluginManagerInterface, CachedDiscoveryInterface, CacheableDependencyInterface {

  /**
   * @var \Drupal\views\Plugin\ViewsPluginManager
   */
  protected $viewsPluginManager;

  /**
   * MetatagViewsCachePluginManager constructor.
   *
   * @param \Drupal\views\Plugin\ViewsPluginManager $views_plugin_manager
   */
  public function __construct(ViewsPluginManager $views_plugin_manager) {
    $this->viewsPluginManager = $views_plugin_manager;
  }

  /**
   * @param \Drupal\views\Plugin\views\cache\CachePluginBase $plugin
   *
   * @return \Drupal\metatag_views\MetatagViewsCacheWrapper
   */
  protected function wrap(CachePluginBase $plugin) {
    return new MetatagViewsCacheWrapper($plugin);
  }

  /**
   * {@inheritdoc}
   */
  public function createInstance($plugin_id, array $configuration = []) {
    return $this
      ->wrap($this->viewsPluginManager
      ->createInstance($plugin_id, $configuration));
  }

  /**
   * {@inheritdoc}
   */
  public function getInstance(array $options) {
    return $this
      ->wrap($this->viewsPluginManager
      ->getInstance($options));
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return $this->viewsPluginManager
      ->getCacheContexts();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return $this->viewsPluginManager
      ->getCacheTags();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return $this->viewsPluginManager
      ->getCacheMaxAge();
  }

  /**
   * {@inheritdoc}
   */
  public function clearCachedDefinitions() {
    $this->viewsPluginManager
      ->clearCachedDefinitions();
  }

  /**
   * {@inheritdoc}
   */
  public function useCaches($use_caches = FALSE) {
    $this->viewsPluginManager
      ->useCaches($use_caches);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
    return $this->viewsPluginManager
      ->getDefinition($plugin_id, $exception_on_invalid);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinitions() {
    return $this->viewsPluginManager
      ->getDefinitions();
  }

  /**
   * {@inheritdoc}
   */
  public function hasDefinition($plugin_id) {
    return $this->viewsPluginManager
      ->hasDefinition($plugin_id);
  }

}

Classes