class InlineBlockDeriver

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php \Drupal\layout_builder\Plugin\Derivative\InlineBlockDeriver
  2. 8.9.x core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php \Drupal\layout_builder\Plugin\Derivative\InlineBlockDeriver
  3. 10 core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php \Drupal\layout_builder\Plugin\Derivative\InlineBlockDeriver

Provides inline block plugin definitions for all block types.

@internal Plugin derivers are internal.

Hierarchy

Expanded class hierarchy of InlineBlockDeriver

File

core/modules/layout_builder/src/Plugin/Derivative/InlineBlockDeriver.php, line 16

Namespace

Drupal\layout_builder\Plugin\Derivative
View source
class InlineBlockDeriver extends DeriverBase implements ContainerDeriverInterface {
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Constructs a BlockContentDeriver object.
     *
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     */
    public function __construct(EntityTypeManagerInterface $entity_type_manager) {
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        $this->derivatives = [];
        if ($this->entityTypeManager
            ->hasDefinition('block_content_type')) {
            $block_content_types = $this->entityTypeManager
                ->getStorage('block_content_type')
                ->loadMultiple();
            foreach ($block_content_types as $id => $type) {
                $this->derivatives[$id] = $base_plugin_definition;
                $this->derivatives[$id]['admin_label'] = $type->label();
                $this->derivatives[$id]['config_dependencies'][$type->getConfigDependencyKey()][] = $type->getConfigDependencyName();
            }
        }
        return parent::getDerivativeDefinitions($base_plugin_definition);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
InlineBlockDeriver::$entityTypeManager protected property The entity type manager.
InlineBlockDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
InlineBlockDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
InlineBlockDeriver::__construct public function Constructs a BlockContentDeriver object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.