You are here

class GroupMenuBlock in Group Content Menu 8

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

Provides block plugin definitions for custom menus.

Hierarchy

Expanded class hierarchy of GroupMenuBlock

File

src/Plugin/Derivative/GroupMenuBlock.php, line 13

Namespace

Drupal\group_content_menu\Plugin\Derivative
View source
class GroupMenuBlock extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The menu storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $menuStorage;

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

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

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

}

Members

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