Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/routing/Loader/ObjectRouteLoader.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
43 * @return RouteCollection | 43 * @return RouteCollection |
44 */ | 44 */ |
45 public function load($resource, $type = null) | 45 public function load($resource, $type = null) |
46 { | 46 { |
47 $parts = explode(':', $resource); | 47 $parts = explode(':', $resource); |
48 if (2 != count($parts)) { | 48 if (2 != \count($parts)) { |
49 throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service_name:methodName"', $resource)); | 49 throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service_name:methodName"', $resource)); |
50 } | 50 } |
51 | 51 |
52 $serviceString = $parts[0]; | 52 $serviceString = $parts[0]; |
53 $method = $parts[1]; | 53 $method = $parts[1]; |
54 | 54 |
55 $loaderObject = $this->getServiceObject($serviceString); | 55 $loaderObject = $this->getServiceObject($serviceString); |
56 | 56 |
57 if (!is_object($loaderObject)) { | 57 if (!\is_object($loaderObject)) { |
58 throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', get_class($this), gettype($loaderObject))); | 58 throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject))); |
59 } | 59 } |
60 | 60 |
61 if (!method_exists($loaderObject, $method)) { | 61 if (!method_exists($loaderObject, $method)) { |
62 throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, get_class($loaderObject), $resource)); | 62 throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource)); |
63 } | 63 } |
64 | 64 |
65 $routeCollection = call_user_func(array($loaderObject, $method), $this); | 65 $routeCollection = \call_user_func([$loaderObject, $method], $this); |
66 | 66 |
67 if (!$routeCollection instanceof RouteCollection) { | 67 if (!$routeCollection instanceof RouteCollection) { |
68 $type = is_object($routeCollection) ? get_class($routeCollection) : gettype($routeCollection); | 68 $type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection); |
69 | 69 |
70 throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', get_class($loaderObject), $method, $type)); | 70 throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', \get_class($loaderObject), $method, $type)); |
71 } | 71 } |
72 | 72 |
73 // make the service file tracked so that if it changes, the cache rebuilds | 73 // make the service file tracked so that if it changes, the cache rebuilds |
74 $this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection); | 74 $this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection); |
75 | 75 |