Skip to content
Snippets Groups Projects
Commit 12eba562 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1980464 by Xano: EntityManager::getControllerClass() throws confusing exceptions.

parent 34aaed60
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -154,8 +154,12 @@ public function hasController($entity_type, $controller_type) {
public function getControllerClass($entity_type, $controller_type, $nested = NULL) {
$definition = $this->getDefinition($entity_type);
$definition = $definition['controllers'];
if (!$definition) {
throw new \InvalidArgumentException(sprintf('The entity type (%s) does not exist.', $entity_type));
}
if (empty($definition[$controller_type])) {
throw new \InvalidArgumentException(sprintf('The entity (%s) did not specify a %s.', $entity_type, $controller_type));
throw new \InvalidArgumentException(sprintf('The entity type (%s) did not specify a %s controller.', $entity_type, $controller_type));
}
$class = $definition[$controller_type];
......@@ -163,14 +167,14 @@ public function getControllerClass($entity_type, $controller_type, $nested = NUL
// Some class definitions can be nested.
if (isset($nested)) {
if (empty($class[$nested])) {
throw new \InvalidArgumentException(sprintf("Missing '%s: %s' for entity '%s'", $controller_type, $nested, $entity_type));
throw new \InvalidArgumentException(sprintf("The entity type (%s) did not specify a %s controller: %s.", $entity_type, $controller_type, $nested));
}
$class = $class[$nested];
}
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Entity (%s) %s "%s" does not exist.', $entity_type, $controller_type, $class));
throw new \InvalidArgumentException(sprintf('The entity type (%s) %s controller "%s" does not exist.', $entity_type, $controller_type, $class));
}
return $class;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment