Commit 12eba562 authored by alexpott's avatar alexpott
Browse files

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

parent 34aaed60
...@@ -154,8 +154,12 @@ public function hasController($entity_type, $controller_type) { ...@@ -154,8 +154,12 @@ public function hasController($entity_type, $controller_type) {
public function getControllerClass($entity_type, $controller_type, $nested = NULL) { public function getControllerClass($entity_type, $controller_type, $nested = NULL) {
$definition = $this->getDefinition($entity_type); $definition = $this->getDefinition($entity_type);
$definition = $definition['controllers']; $definition = $definition['controllers'];
if (!$definition) {
throw new \InvalidArgumentException(sprintf('The entity type (%s) does not exist.', $entity_type));
}
if (empty($definition[$controller_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]; $class = $definition[$controller_type];
...@@ -163,14 +167,14 @@ public function getControllerClass($entity_type, $controller_type, $nested = NUL ...@@ -163,14 +167,14 @@ public function getControllerClass($entity_type, $controller_type, $nested = NUL
// Some class definitions can be nested. // Some class definitions can be nested.
if (isset($nested)) { if (isset($nested)) {
if (empty($class[$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]; $class = $class[$nested];
} }
if (!class_exists($class)) { 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; return $class;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment