3 namespace Drupal\layout_builder\Plugin\Derivative;
5 use Drupal\Component\Plugin\Derivative\DeriverBase;
6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides inline block plugin definitions for all custom block types.
15 class InlineBlockDeriver extends DeriverBase implements ContainerDeriverInterface {
18 * The entity type manager.
20 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
22 protected $entityTypeManager;
25 * Constructs a BlockContentDeriver object.
27 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
28 * The entity type manager.
30 public function __construct(EntityTypeManagerInterface $entity_type_manager) {
31 $this->entityTypeManager = $entity_type_manager;
37 public static function create(ContainerInterface $container, $base_plugin_id) {
39 $container->get('entity_type.manager')
46 public function getDerivativeDefinitions($base_plugin_definition) {
47 $this->derivatives = [];
48 if ($this->entityTypeManager->hasDefinition('block_content_type')) {
49 $block_content_types = $this->entityTypeManager->getStorage('block_content_type')->loadMultiple();
50 foreach ($block_content_types as $id => $type) {
51 $this->derivatives[$id] = $base_plugin_definition;
52 $this->derivatives[$id]['admin_label'] = $type->label();
53 $this->derivatives[$id]['config_dependencies'][$type->getConfigDependencyKey()][] = $type->getConfigDependencyName();
56 return parent::getDerivativeDefinitions($base_plugin_definition);