By e0ipso on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
3.x
Introduced in version:
3.0.0
Issue links:
Description:
Before this change trying to wrap an entity that did not have a suitable wrapper would lead to a RepositoryNotFound exception. Now it will return NULL.
Consider this example in 2.x:
function physical_media_node_access($node, $op, $account) {
try {
$wrapped_node = \Drupal::service(RepositoryManager::class)->wrap($node);
}
catch (RepositoryNotFoundException $exception) {
return AccessResult::neutral();
}
return $wrapped_node instanceof AccessibleInterface
? $wrapped_node->access($op, $account, TRUE)
: AccessResult::neutral();
}
In this example we want node types that have no associated wrapper to return access neutral. In 3.x the code should look like:
function physical_media_node_access($node, $op, $account) {
$wrapped_node = typed_entity_repository_manager()->wrap($node);
return $wrapped_node instanceof AccessibleInterface
? $wrapped_node->access($op, $account, TRUE)
: AccessResult::neutral();
}
Impacts:
Module developers