예제 #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);
 }
예제 #2
0
 /**
  * {@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);
         }
     }
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function onBlockAdministrativeContext(BlockContextEvent $event)
 {
     $context = new Context(new ContextDefinition('entity:node'));
     $event->setContext('node.node', $context);
 }