You are here

class BlocktabsBlock in Block Tabs 8

Same name in this branch
  1. 8 src/Plugin/Derivative/BlocktabsBlock.php \Drupal\blocktabs\Plugin\Derivative\BlocktabsBlock
  2. 8 src/Plugin/Block/BlocktabsBlock.php \Drupal\blocktabs\Plugin\Block\BlocktabsBlock

Provides block plugin definitions for blocktabs.

Hierarchy

Expanded class hierarchy of BlocktabsBlock

See also

\Drupal\blocktabs\Plugin\Block\BlocktabsBlock

File

src/Plugin/Derivative/BlocktabsBlock.php, line 15

Namespace

Drupal\blocktabs\Plugin\Derivative
View source
class BlocktabsBlock extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The entity storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $entityStorage;

  /**
   * Constructs new SystemMenuBlock.
   *
   * @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage
   *   The entity storage.
   */
  public function __construct(EntityStorageInterface $entity_storage) {
    $this->entityStorage = $entity_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('entity_type.manager')
      ->getStorage('blocktabs'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityStorage
      ->loadMultiple() as $blocktabs => $entity) {
      $this->derivatives[$blocktabs] = $base_plugin_definition;
      $this->derivatives[$blocktabs]['admin_label'] = 'Blocktabs:' . $entity
        ->label();
      $this->derivatives[$blocktabs]['config_dependencies']['config'] = [
        $entity
          ->getConfigDependencyName(),
      ];
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlocktabsBlock::$entityStorage protected property The entity storage.
BlocktabsBlock::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
BlocktabsBlock::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
BlocktabsBlock::__construct public function Constructs new SystemMenuBlock.
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition