View source
<?php
namespace Drupal\render_cache\ServiceContainer\ServiceProvider;
use Drupal\service_container\DependencyInjection\ServiceProviderInterface;
class RenderCacheServiceProvider implements ServiceProviderInterface {
public function getContainerDefinition() {
$parameters = array();
$parameters['cache_contexts'] = array();
$parameters['service_container.static_event_listeners'] = array(
'RenderCache',
);
$services = array();
$services['cache_contexts'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\CacheContexts',
'arguments' => array(
'@service_container',
'%cache_contexts%',
),
);
$services['cache_context.url'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\UrlCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$services['cache_context.language'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\LanguageCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$services['cache_context.theme'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\ThemeCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$services['cache_context.theme'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\TimezoneCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$services['render_stack'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\RenderStack',
);
$services['render_cache.cache'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\RenderCacheBackendAdapter',
'arguments' => array(
'@render_stack',
),
);
$services['cache_context.user'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\UserCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$services['cache_context.user.roles'] = array(
'class' => '\\Drupal\\render_cache\\Cache\\UserRolesCacheContext',
'tags' => array(
array(
'name' => 'cache.context',
),
),
);
$parameters['ctools_plugins_auto_discovery.render_cache'] = array(
'render_cache',
);
return array(
'parameters' => $parameters,
'services' => $services,
);
}
public function alterContainerDefinition(&$container_definition) {
$container_definition['parameters']['cache_contexts'] = array_keys($container_definition['tags']['cache.context']);
}
}