diff core/lib/Drupal/Core/Access/CustomAccessCheck.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/core/lib/Drupal/Core/Access/CustomAccessCheck.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/core/lib/Drupal/Core/Access/CustomAccessCheck.php	Thu Feb 28 13:21:36 2019 +0000
@@ -61,7 +61,14 @@
    *   The access result.
    */
   public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
-    $callable = $this->controllerResolver->getControllerFromDefinition($route->getRequirement('_custom_access'));
+    try {
+      $callable = $this->controllerResolver->getControllerFromDefinition($route->getRequirement('_custom_access'));
+    }
+    catch (\InvalidArgumentException $e) {
+      // The custom access controller method was not found.
+      throw new \BadMethodCallException(sprintf('The "%s" method is not callable as a _custom_access callback in route "%s"', $route->getRequirement('_custom_access'), $route->getPath()));
+    }
+
     $arguments_resolver = $this->argumentsResolverFactory->getArgumentsResolver($route_match, $account);
     $arguments = $arguments_resolver->getArguments($callable);