function SiteContext::getRuntimeContexts
Overrides ContextProviderInterface::getRuntimeContexts
1 call to SiteContext::getRuntimeContexts()
- SiteContext::getAvailableContexts in src/
ContextProvider/ SiteContext.php - Gets all available contexts for the purposes of configuration.
File
-
src/
ContextProvider/ SiteContext.php, line 46
Class
- SiteContext
- Sets the current node as a context on node routes.
Namespace
Drupal\rules\ContextProviderCode
public function getRuntimeContexts(array $unqualified_context_ids) {
$site = [
'url' => Url::fromRoute('<front>', [], [
'absolute' => TRUE,
])->toString(),
'login-url' => Url::fromRoute('user.page', [], [
'absolute' => TRUE,
])->toString(),
'name' => $this->systemSiteConfig
->get('name'),
'slogan' => $this->systemSiteConfig
->get('slogan'),
'mail' => $this->systemSiteConfig
->get('mail'),
];
$context_definition = new ContextDefinition('site', $this->t('Site information'));
$context = new Context($context_definition, $site);
$cacheability = new CacheableMetadata();
$cacheability->setCacheContexts([
'site',
]);
$context->addCacheableDependency($cacheability);
$result = [
'site' => $context,
];
return $result;
}