public function UserDashboardSectionStorage::deriveContextsFromRoute in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Plugin/SectionStorage/UserDashboardSectionStorage.php \Drupal\dashboards\Plugin\SectionStorage\UserDashboardSectionStorage::deriveContextsFromRoute()
Derives the available plugin contexts from route values.
This should only be called during section storage instantiation, specifically for use by the routing system. For all non-routing usages, use \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextValue().
Parameters
mixed $value: The raw value.
mixed $definition: The parameter definition provided in the route options.
string $name: The name of the parameter.
array $defaults: The route defaults array.
Return value
\Drupal\Core\Plugin\Context\ContextInterface[] The available plugin contexts.
Overrides DashboardSectionStorage::deriveContextsFromRoute
See also
\Drupal\Core\ParamConverter\ParamConverterInterface::convert()
File
- src/
Plugin/ SectionStorage/ UserDashboardSectionStorage.php, line 99
Class
- UserDashboardSectionStorage
- Class DashboardSectionStorage.
Namespace
Drupal\dashboards\Plugin\SectionStorageCode
public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {
$contexts = [];
$id = !empty($value) ? $value : (!empty($defaults['dashboard']) ? $defaults['dashboard'] : NULL);
/**
* @var \Drupal\dashboards\Entity\Dashboard $entity
*/
if ($id && ($entity = $this->entityTypeManager
->getStorage('dashboard')
->load($id))) {
if ($entity
->isOverriden()) {
$entity
->loadOverrides();
}
$contexts[Dashboard::CONTEXT_TYPE] = EntityContext::fromEntity($entity);
}
return $contexts;
}