protected function FormAlter::getBlockDefinitions in Layout Builder Restrictions 8
Gets block definitions appropriate for an entity display.
Parameters
\Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $display: The entity display being edited.
Return value
array[] Keys are category names, and values are arrays of which the keys are plugin IDs and the values are plugin definitions.
1 call to FormAlter::getBlockDefinitions()
- FormAlter::alterEntityViewDisplayForm in src/
Form/ FormAlter.php - The actual form elements.
File
- src/
Form/ FormAlter.php, line 106
Class
- FormAlter
- Supplement form UI to add setting for which blocks & layouts are available.
Namespace
Drupal\layout_builder_restrictions\FormCode
protected function getBlockDefinitions(LayoutEntityDisplayInterface $display) {
// Check for 'load' method, which only exists in > 8.7.
if (method_exists($this->sectionStorageManager, 'load')) {
$section_storage = $this->sectionStorageManager
->load('defaults', [
'display' => EntityContext::fromEntity($display),
]);
}
else {
// BC for < 8.7.
$section_storage = $this->sectionStorageManager
->loadEmpty('defaults')
->setSectionList($display);
}
// Do not use the plugin filterer here, but still filter by contexts.
$definitions = $this->blockManager
->getDefinitions();
$definitions = $this->contextHandler
->filterPluginDefinitionsByContexts($this
->getAvailableContexts($section_storage), $definitions);
return $this->blockManager
->getGroupedDefinitions($definitions);
}