| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/lemans/libraries/kunena/src/Request/ |
Upload File : |
<?php
/**
* Kunena Component
*
* @package Kunena.Administrator.Template
* @subpackage Categories
*
* @copyright Copyright (C) 2008 - @currentyear@ Kunena Team. All rights reserved.
* @license https://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
namespace Kunena\Forum\Libraries\Request;
\defined('_JEXEC') or die();
use InvalidArgumentException;
use Joomla\Input\Input;
use Kunena\Forum\Libraries\Controller\KunenaControllerBase;
/**
* implements \Kunena Request class.
*
* This class is part of Kunena HMVC implementation, allowing calls to
* any display controller in the component.
*
* <code>
* // Executes the controller and sets the layout for the view.
* echo \Kunena\Forum\Libraries\Request\Request::factory('User/Login')->execute()->set('layout', 'form');
*
* // If there are no parameters for the view, this shorthand works also.
* echo \Kunena\Forum\Libraries\Request\Request::factory('User/Registration');
* </code>
*
* Individual controller classes are located in /components/com_kunena/controller
* sub-folders eg: controller/user/login/display.php
*
* @see KunenaLayout
* @since Kunena 6.0
*/
class KunenaRequest
{
/**
* Returns controller.
*
* @param string $path Controller path.
* @param Input|null $input input
* @param mixed $options options
*
* @return KunenaControllerBase| KunenaControllerDisplay
*
* @throws \Exception
*@since Kunena 6.0
*/
public static function factory(string $path, ?Input $input = null, $options = null)
{
// Normalize input.
$words = ucwords(strtolower(trim(preg_replace('/[^a-z0-9_]+/i', ' ', (string) $path))));
if (!$words) {
throw new InvalidArgumentException('No controller given.', 404);
}
// Attempt to load controller.
$ex = explode(' ', $words);
$subpart = '';
if (\count($ex) == 4) {
$subpart = '' . $ex[2] . '\\';
}
$classnamespaced = 'Kunena\Forum\Site\Controller\\' . $ex[0] . '\\' . $ex[1] . '\\' . $subpart . str_replace(' ', '', $words);
if (!class_exists($classnamespaced)) {
throw new InvalidArgumentException(sprintf('In the KunenaRequest class the controller %s doesn\'t exist.', $classnamespaced), 404);
}
// Create controller object.
return new $classnamespaced($input, null, $options);
}
}