/** * Set convetions callable for route. * Convertions allow to freely transform the route’s parameters before passing them to the dispatcher. * * @param Route $route * @param array $convertions */ protected function setConvertions(Route $route, array $convertions) { foreach ($convertions as $convertionName => $convertConfig) { $obj = $this->getInstanceHelper($convertConfig); $isCallable = is_callable($obj); if (!$isCallable && !$obj instanceof ConvertingInterface) { $errMsg = sprintf('"%s" must be implemented "%s"', get_class($obj), ConvertingInterface::class); throw new Exception\RuntimeException($errMsg); } $converter = $isCallable ? $obj : [$obj, 'convert']; $route->convert($convertionName, $converter); } }