Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     // Optimize cache context, if a user cache context is provided, only use
     // user.roles, since that's the only part this condition cares about.
     $contexts = [];
     foreach (parent::getCacheContexts() as $context) {
         $contexts[] = $context == 'user' ? 'user.roles' : $context;
     }
     return $contexts;
 }
 /**
  * {@inheritdoc}
  */
 public function getContextValue($name)
 {
     try {
         return parent::getContextValue($name);
     } catch (ContextException $e) {
         // Catch the undocumented exception thrown when no context value is set
         // for a required context.
         // @todo: Remove once https://www.drupal.org/node/2677162 is fixed.
         if (strpos($e->getMessage(), 'context is required') === FALSE) {
             throw $e;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     return ['age' => NULL] + parent::defaultConfiguration();
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     $contexts = parent::getCacheContexts();
     // @todo Add a url.path cache context in
     //   https://www.drupal.org/node/2521978.
     $contexts[] = 'url';
     return $contexts;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $this->configuration['domains'] = array_filter($form_state->getValue('domains'));
     parent::submitConfigurationForm($form, $form_state);
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     $config = ['facets' => FALSE, 'facet_value' => FALSE];
     return $config + parent::defaultConfiguration();
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, array &$form_state)
 {
     $this->configuration['pages'] = $form_state['values']['pages'];
     parent::submitConfigurationForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     return array('bundles' => array()) + parent::defaultConfiguration();
 }
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     return ['operations' => ['manage event' => TRUE]] + parent::defaultConfiguration();
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     $contexts = parent::getCacheContexts();
     $contexts[] = 'theme';
     return $contexts;
 }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $this->configuration['theme'] = $form_state['values']['theme'];
     parent::submitConfigurationForm($form, $form_state);
 }
Example #12
0
 public function __construct(RequestStack $requestStack, array $configuration, $plugin_id, $plugin_definition)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->requestStack = $requestStack;
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     return array('collections' => FALSE) + parent::defaultConfiguration();
 }
 /**
  * {@inheritdoc}
  */
 public function defaultConfiguration()
 {
     return array('module' => '') + parent::defaultConfiguration();
 }
Example #15
0
 /**
  * {inheritdoc}.
  */
 public function getCacheTags() {
   $tags = parent::getCacheTags();
   if (!empty($this->configuration['block_visibility_group'])) {
     if ($group = $this->entityStorage->load($this->configuration['block_visibility_group'])) {
       $tags = Cache::mergeTags($tags, $group->getCacheTags());
     }
   }
   return $tags;
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function getCacheContexts()
 {
     $contexts = parent::getCacheContexts();
     $contexts[] = 'url.path';
     return $contexts;
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, array &$form_state)
 {
     $this->configuration['roles'] = array_filter($form_state['values']['roles']);
     parent::submitConfigurationForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $this->configuration['pages'] = $form_state->getValue('pages');
     parent::submitConfigurationForm($form, $form_state);
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitConfigurationForm($form, $form_state);
     $this->configuration['date'] = $form_state->getValue('date')->format('U');
 }