Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function onBlockActiveContext(BlockContextEvent $event)
 {
     $current_user = $this->userStorage->load($this->account->id());
     $context = new Context(new ContextDefinition('entity:user', $this->t('Current user')));
     $context->setContextValue($current_user);
     $event->setContext('user.current_user', $context);
 }
 /**
  * {@inheritdoc}
  */
 public function onBlockActiveContext(BlockContextEvent $event)
 {
     // Add a context for each language type.
     $language_types = $this->languageManager->getLanguageTypes();
     $info = $this->languageManager->getDefinedLanguageTypesInfo();
     foreach ($language_types as $type_key) {
         if (isset($info[$type_key]['name'])) {
             $context = new Context(new ContextDefinition('language', $info[$type_key]['name']));
             $context->setContextValue($this->languageManager->getCurrentLanguage($type_key));
             $event->setContext('language.' . $type_key, $context);
         }
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function onBlockAdministrativeContext(BlockContextEvent $event)
 {
     $context = new Context(new ContextDefinition('entity:node'));
     $event->setContext('node.node', $context);
 }