Пример #1
0
 /**
  * Gets a cache controller based on the data to be rendered.
  *
  * @param mixed $data
  *   The data to be rendered.
  *
  * @return RenderCacheInterface
  *   The cache controller.
  */
 protected function createCacheController($data)
 {
     if (!($cache_fragments = $this->cacheFragments($data))) {
         return NULL;
     }
     // Add the formatter fragment because every formatter may prepare the data
     // differently.
     /* @var \Doctrine\Common\Collections\ArrayCollection $cache_fragments */
     $cache_fragments->set('formatter', $this->getPluginId());
     /* @var \Drupal\restful\Plugin\resource\Decorators\CacheDecoratedResource $cached_resource */
     if (!($cached_resource = $this->getResource())) {
         return NULL;
     }
     if (!$cached_resource instanceof CacheDecoratedResourceInterface) {
         return NULL;
     }
     return RenderCache::create($cache_fragments, $cached_resource->getCacheController());
 }
 /**
  * Clears the cache entries related to the given cache fragments.
  *
  * @param \Doctrine\Common\Collections\ArrayCollection $cache_fragments
  *   The cache fragments to clear.
  */
 protected function clearRenderedCache(ArrayCollection $cache_fragments)
 {
     $cache_object = new RenderCache($cache_fragments, NULL, $this->cacheController);
     $cache_object->clear();
 }