/** * {@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(); }
/** * {@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; }
/** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['domains'] = array_filter($form_state->getValue('domains')); parent::submitConfigurationForm($form, $form_state); }
/** * {@inheritdoc} */ public function defaultConfiguration() { $config = ['facets' => FALSE, 'facet_value' => FALSE]; return $config + parent::defaultConfiguration(); }
/** * {@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(); }
/** * {@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); }
public function __construct(RequestStack $requestStack, array $configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->requestStack = $requestStack; }
/** * {@inheritdoc} */ public function defaultConfiguration() { return array('collections' => FALSE) + parent::defaultConfiguration(); }
/** * {@inheritdoc} */ public function defaultConfiguration() { return array('module' => '') + parent::defaultConfiguration(); }
/** * {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; }
/** * {@inheritdoc} */ public function getCacheContexts() { $contexts = parent::getCacheContexts(); $contexts[] = 'url.path'; return $contexts; }
/** * {@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); }
/** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['date'] = $form_state->getValue('date')->format('U'); }