diff --git a/src/ajax/core/Bans.php b/src/ajax/core/Bans.php index fddb322fd..8e52c23b8 100644 --- a/src/ajax/core/Bans.php +++ b/src/ajax/core/Bans.php @@ -20,6 +20,7 @@ use LotgdTranslator; use Throwable; use Tracy\Debugger; +use function Jaxon\jaxon; class Bans extends AjaxAbstract { @@ -27,7 +28,7 @@ public function showAffected($ip, $id) { global $session; - $response = new Response(); + $response = jaxon()->getResponse(); try { diff --git a/src/ajax/core/Mounts.php b/src/ajax/core/Mounts.php index b209d51c6..4e61dbb5e 100644 --- a/src/ajax/core/Mounts.php +++ b/src/ajax/core/Mounts.php @@ -20,6 +20,7 @@ use LotgdTranslator; use Throwable; use Tracy\Debugger; +use function Jaxon\jaxon; class Mounts extends AjaxAbstract { @@ -32,7 +33,7 @@ public function getListOfOwners(int $mountId) return $check; } - $response = new Response(); + $response = jaxon()->getResponse(); try { diff --git a/src/core/AjaxAbstract.php b/src/core/AjaxAbstract.php index 201a92f10..e8a57d5f5 100644 --- a/src/core/AjaxAbstract.php +++ b/src/core/AjaxAbstract.php @@ -13,7 +13,7 @@ namespace Lotgd\Core; -use Jaxon\Response\Response; +use function Jaxon\jaxon; /** * Use this class to add a basic function to your Jaxon request. @@ -24,7 +24,7 @@ abstract class AjaxAbstract /** * Return true or empty Jaxon\Response\Response. * - * @return true|Response + * @return \Jaxon\Response\ResponseInterface|true */ protected function checkLoggedIn() { @@ -33,7 +33,7 @@ protected function checkLoggedIn() //-- Do nothing if there is no active session if ( ! ($session['user']['loggedin'] ?? false)) { - return new Response(); + return jaxon()->getResponse(); } return true; @@ -42,7 +42,7 @@ protected function checkLoggedIn() /** * Return true or redirect to home.php page. * - * @return true|Redirect + * @return \Jaxon\Response\ResponseInterface|true */ protected function checkLoggedInRedirect() { @@ -51,7 +51,7 @@ protected function checkLoggedInRedirect() //-- Do nothing if there is no active session if ( ! ($session['user']['loggedin'] ?? false)) { - $response = new Response(); + $response = jaxon()->getResponse(); return $response->redirect('home.php'); } diff --git a/src/core/Service/Jaxon.php b/src/core/Service/Jaxon.php index 750f90141..4410a265b 100644 --- a/src/core/Service/Jaxon.php +++ b/src/core/Service/Jaxon.php @@ -13,22 +13,20 @@ namespace Lotgd\Core\Service; +use Jaxon\App\Ajax; use Jaxon\Jaxon as JaxonCore; +use function Jaxon\jaxon; -class Jaxon extends JaxonCore +class Jaxon extends Ajax { public function __construct(array $config) { - parent::__construct(); - - $this->di()->getConfig()->setOptions($config); + $this->config()->setOptions($config); //-- Register all class of Lotgd in dir "src/ajax/core" $this->register(JaxonCore::CALLABLE_DIR, './src/ajax/core', ['namespace' => 'Lotgd\\Ajax\\Core\\']); //-- Register all custom class (Available globally) in dir "src/ajax/local" $this->register(JaxonCore::CALLABLE_DIR, './src/ajax/local', ['namespace' => 'Lotgd\\Ajax\\Local\\']); - - $this->plugin('dialog')->registerClasses(); } }