/**
  * Creates a SystemHelpBlock instance.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
  *   The module handler.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The current route match.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request, ModuleHandlerInterface $module_handler, RouteMatchInterface $route_match)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->request = $request;
     $this->moduleHandler = $module_handler;
     $this->routeMatch = $route_match;
 }
 /**
  * Constructs a new BlockContentBlock.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin ID for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\block\BlockManagerInterface
  *   The Plugin Block Manager.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager service.
  * @param \Drupal\Core\Extension\ModuleHandlerInterface
  *   The Module Handler.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The account for which view access should be checked.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, BlockManagerInterface $block_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $account)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->blockManager = $block_manager;
     $this->entityManager = $entity_manager;
     $this->moduleHandler = $module_handler;
     $this->account = $account;
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, array &$form_state)
 {
     $form = parent::buildConfigurationForm($form, $form_state);
     // The main content block is never cacheable, because it may be dynamic.
     $form['cache']['#disabled'] = TRUE;
     $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.');
     $form['cache']['max_age']['#value'] = 0;
     return $form;
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, array &$form_state)
 {
     $form = parent::buildConfigurationForm($form, $form_state);
     // @see ::isCacheable()
     $form['cache']['#disabled'] = TRUE;
     $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.');
     $form['cache']['max_age']['#value'] = 0;
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildConfigurationForm($form, $form_state);
     // The 'Powered by Drupal' block is permanently cacheable, because its
     // contents can never change.
     $form['cache']['#disabled'] = TRUE;
     $form['cache']['max_age']['#value'] = Cache::PERMANENT;
     $form['cache']['#description'] = t('This block is always cached forever, it is not configurable.');
     return $form;
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function getCacheKeys()
 {
     return array_merge(parent::getCacheKeys(), Cache::keyFromQuery($this->buildForumQuery()));
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function getCacheTags()
 {
     // Even when the menu block renders to the empty string for a user, we want
     // the cache tag for this menu to be set: whenever the menu is changed, this
     // menu block must also be re-rendered for that user, because maybe a menu
     // link that is accessible for that user has been added.
     $tags = array('menu' => array($this->getDerivativeId()));
     return NestedArray::mergeDeep(parent::getCacheTags(), $tags);
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheTags()
 {
     // The theme-specific cache tag is set automatically for each block, but the
     // output of this block also depends on the global theme settings.
     $tags = array('theme_global_setting' => TRUE);
     return NestedArray::mergeDeep(parent::getCacheTags(), $tags);
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheTags()
 {
     $cache_tags = parent::getCacheTags();
     $feed = $this->feedStorage->load($this->configuration['feed']);
     $cache_tags = NestedArray::mergeDeep($cache_tags, $feed->getCacheTag());
     return $cache_tags;
 }
Beispiel #10
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildConfigurationForm($form, $form_state);
     // Set the default label to '' so the views internal title is used.
     $form['label']['#default_value'] = '';
     $form['label']['#access'] = FALSE;
     // Unset the machine_name provided by BlockForm.
     unset($form['id']['#machine_name']['source']);
     // Prevent users from changing the auto-generated block machine_name.
     $form['id']['#access'] = FALSE;
     $form['#pre_render'][] = '\\Drupal\\views\\Plugin\\views\\PluginBase::preRenderAddFieldsetMarkup';
     // Allow to override the label on the actual page.
     $form['views_label_checkbox'] = array('#type' => 'checkbox', '#title' => $this->t('Override title'), '#default_value' => !empty($this->configuration['views_label']));
     $form['views_label_fieldset'] = array('#type' => 'fieldset', '#states' => array('visible' => array(array(':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE)))));
     $form['views_label'] = array('#title' => $this->t('Title'), '#type' => 'textfield', '#default_value' => $this->configuration['views_label'] ?: $this->view->getTitle(), '#states' => array('visible' => array(array(':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE)))), '#fieldset' => 'views_label_fieldset');
     if ($this->view->storage->access('edit') && \Drupal::moduleHandler()->moduleExists('views_ui')) {
         $form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore. (Try changing it directly in <a href="@url">@name</a>.)', array('@url' => \Drupal::url('views_ui.edit_display', array('view' => $this->view->storage->id(), 'display_id' => $this->displayID)), '@name' => $this->view->storage->label()));
     } else {
         $form['views_label']['#description'] = $this->t('Changing the title here means it cannot be dynamically altered anymore.');
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheKeys()
 {
     // Add a key for the active book trail.
     $current_bid = 0;
     if ($node = $this->requestStack->getCurrentRequest()->get('node')) {
         $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
     }
     if ($current_bid === 0) {
         return parent::getCacheKeys();
     }
     $active_trail = $this->bookManager->getActiveTrailIds($node->book['bid'], $node->book);
     $active_trail_key = 'trail.' . implode('|', $active_trail);
     return array_merge(parent::getCacheKeys(), array($active_trail_key));
 }
 /**
  * Constructs a new SystemBreadcrumbBlock object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $breadcrumb_manager
  *   The breadcrumb manager.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The current route match.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, BreadcrumbBuilderInterface $breadcrumb_manager, RouteMatchInterface $route_match)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->breadcrumbManager = $breadcrumb_manager;
     $this->routeMatch = $route_match;
 }
 /**
  * Constructs a new RedirectFormBlock.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
  *   The form builder.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->formBuilder = $form_builder;
 }
Beispiel #14
0
 /**
  * Constructs an LanguageBlock object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
  *   The language manager.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->languageManager = $language_manager;
 }