Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/zenit/libraries/vendor/joomla/application/src/Controller/ |
Upload File : |
<?php
/**
* Part of the Joomla Framework Application Package
*
* @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Application\Controller;
use Joomla\Controller\ControllerInterface;
use Joomla\Router\ResolvedRoute;
/**
* Resolves a controller for the given route.
*
* @since 2.0.0
*/
class ControllerResolver implements ControllerResolverInterface
{
/**
* Resolve the controller for a route
*
* @param ResolvedRoute $route The route to resolve the controller for
*
* @return callable
*
* @since 2.0.0
* @throws \InvalidArgumentException
*/
public function resolve(ResolvedRoute $route): callable
{
$controller = $route->getController();
// Try to resolve a callable defined as an array
if (\is_array($controller))
{
if (isset($controller[0]) && \is_string($controller[0]) && isset($controller[1]))
{
if (!class_exists($controller[0]))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
try
{
$controller[0] = $this->instantiateController($controller[0]);
}
catch (\ArgumentCountError $error)
{
throw new \InvalidArgumentException(
sprintf(
'Controller `%s` has required constructor arguments, cannot instantiate the class', $controller[0]
),
0,
$error
);
}
}
if (!\is_callable($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
return $controller;
}
// Try to resolve an invokable object
if (\is_object($controller))
{
if (!\is_callable($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
return $controller;
}
// Try to resolve a known function
if (\function_exists($controller))
{
return $controller;
}
// Try to resolve a class name if it implements our ControllerInterface
if (\is_string($controller) && interface_exists(ControllerInterface::class))
{
if (!class_exists($controller))
{
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
try
{
return [$this->instantiateController($controller), 'execute'];
}
catch (\ArgumentCountError $error)
{
throw new \InvalidArgumentException(
sprintf(
'Controller `%s` has required constructor arguments, cannot instantiate the class', $controller
),
0,
$error
);
}
}
// Unsupported resolution
throw new \InvalidArgumentException(sprintf('Cannot resolve controller for URI `%s`', $route->getUri()));
}
/**
* Instantiate a controller class
*
* @param string $class The class to instantiate
*
* @return object Controller class instance
*
* @since 2.0.0
*/
protected function instantiateController(string $class): object
{
return new $class;
}
}