You are here

class BlockFieldManager in Block field 8

Defines a service that manages block plugins for the block field.

Hierarchy

Expanded class hierarchy of BlockFieldManager

1 string reference to 'BlockFieldManager'
block_field.services.yml in ./block_field.services.yml
block_field.services.yml
1 service uses BlockFieldManager
block_field.manager in ./block_field.services.yml
Drupal\block_field\BlockFieldManager

File

src/BlockFieldManager.php, line 11

Namespace

Drupal\block_field
View source
class BlockFieldManager implements BlockFieldManagerInterface {

  /**
   * The block plugin manager.
   *
   * @var \Drupal\Core\Block\BlockManagerInterface
   */
  protected $blockManager;

  /**
   * The context repository.
   *
   * @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface
   */
  protected $contextRepository;

  /**
   * Constructs a new BlockFieldManager.
   *
   * @param \Drupal\Core\Block\BlockManagerInterface $block_manager
   *   The block plugin manager.
   * @param \Drupal\Core\Plugin\Context\ContextRepositoryInterface $context_repository
   *   The context repository.
   */
  public function __construct(BlockManagerInterface $block_manager, ContextRepositoryInterface $context_repository) {
    $this->blockManager = $block_manager;
    $this->contextRepository = $context_repository;
  }

  /**
   * {@inheritdoc}
   */
  public function getBlockDefinitions() {
    $definitions = $this->blockManager
      ->getDefinitionsForContexts($this->contextRepository
      ->getAvailableContexts());
    return $this->blockManager
      ->getSortedDefinitions($definitions);
  }

  /**
   * {@inheritdoc}
   */
  public function getBlockCategories() {
    return $this->blockManager
      ->getCategories();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlockFieldManager::$blockManager protected property The block plugin manager.
BlockFieldManager::$contextRepository protected property The context repository.
BlockFieldManager::getBlockCategories public function Get list of all block categories. Overrides BlockFieldManagerInterface::getBlockCategories
BlockFieldManager::getBlockDefinitions public function Get sorted listed of supported block definitions. Overrides BlockFieldManagerInterface::getBlockDefinitions
BlockFieldManager::__construct public function Constructs a new BlockFieldManager.