You are here

class DashboardBlockBase in Content Planner 8

Implements DashboardBlockBase.

Hierarchy

Expanded class hierarchy of DashboardBlockBase

7 files declare their use of DashboardBlockBase
ContentStateStatistic.php in modules/content_kanban/src/Plugin/DashboardBlock/ContentStateStatistic.php
CustomHTMLBlockBase.php in src/Plugin/DashboardBlock/CustomHTMLBlockBase.php
DashboardSettingsForm.php in src/Form/DashboardSettingsForm.php
RecentCalendarPublicationsBlock.php in modules/content_calendar/src/Plugin/DashboardBlock/RecentCalendarPublicationsBlock.php
RecentKanbanActivities.php in modules/content_kanban/src/Plugin/DashboardBlock/RecentKanbanActivities.php

... See full list

File

src/DashboardBlockBase.php, line 17

Namespace

Drupal\content_planner
View source
class DashboardBlockBase extends PluginBase implements DashboardBlockInterface, ContainerFactoryPluginInterface {
  use ConfigFormBaseTrait;

  /**
   * The route match.
   *
   * @var \Drupal\Core\Entity\EntityTypeManager
   */
  protected $entityTypeManager;

  /**
   * Constructs a new UserLoginBlock instance.
   *
   * @param array $configuration
   *   The plugin configuration, i.e. an array with configuration values keyed
   *   by configuration option name. The special key 'context' may be used to
   *   initialize the defined contexts by setting it to an array of context
   *   values keyed by context names.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'));
  }

  /**
   * Gets the configuration names that will be editable.
   *
   * @return array
   *   An array of configuration object names that are editable if called in
   *   conjunction with the trait's config() method.
   */
  protected function getEditableConfigNames() {
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return $this->pluginDefinition['name'];
  }

  /**
   * {@inheritdoc}
   */
  public function isConfigurable() {
    if (array_key_exists('configurable', $this->pluginDefinition)) {
      return $this->pluginDefinition['configurable'];
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getConfiguration() {
    return $this->configuration;
  }

  /**
   * Get basic configuration structure for the block configuration.
   *
   * @return array
   *   The basic configuration structure.
   */
  public static function getBasicConfigStructure() {
    return [
      'plugin_id' => NULL,
      'title' => NULL,
      'weight' => 0,
      'configured' => FALSE,
      'plugin_specific_config' => [],
    ];
  }

  /**
   * Get custom config.
   *
   * @param array $block_configuration
   *   The block plugin configuration.
   * @param string $key
   *   The config key.
   * @param mixed $default_value
   *   The default value to return if key does not exist in the specific
   *   configuration.
   *
   * @return mixed|null
   *   The config value or NULL.
   */
  protected function getCustomConfigByKey(array $block_configuration, $key, $default_value = NULL) {

    // If a given key exists in the plugin specific configuration, then return
    // it.
    if (array_key_exists($key, $block_configuration['plugin_specific_config'])) {
      return $block_configuration['plugin_specific_config'][$key];
    }
    return $default_value;
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getConfigSpecificFormFields(FormStateInterface &$form_state, Request &$request, array $block_configuration) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface &$form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitSettingsForm(array &$form, FormStateInterface &$form_state) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DashboardBlockBase::$entityTypeManager protected property The route match.
DashboardBlockBase::build public function Build the block and return a renderable array. Overrides DashboardBlockInterface::build 6
DashboardBlockBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 2
DashboardBlockBase::getBasicConfigStructure public static function Get basic configuration structure for the block configuration.
DashboardBlockBase::getConfigSpecificFormFields public function Add additonal form elements specific to the Plugin. Overrides DashboardBlockInterface::getConfigSpecificFormFields 6
DashboardBlockBase::getConfiguration public function Get Configuration passed in by Plugin Manager. Overrides DashboardBlockInterface::getConfiguration
DashboardBlockBase::getCustomConfigByKey protected function Get custom config.
DashboardBlockBase::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
DashboardBlockBase::getName public function Return the name of the block. Overrides DashboardBlockInterface::getName
DashboardBlockBase::isConfigurable public function Determines if the plugin is configurable. Overrides PluginBase::isConfigurable
DashboardBlockBase::submitSettingsForm public function Submit form handler. Overrides DashboardBlockInterface::submitSettingsForm
DashboardBlockBase::validateForm public function Validates teh plugin config form. Overrides DashboardBlockInterface::validateForm
DashboardBlockBase::__construct public function Constructs a new UserLoginBlock instance. Overrides PluginBase::__construct 2
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId