mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-24 02:44:51 +03:00
code style
This commit is contained in:
parent
5995bc1a53
commit
0d9b10ef8b
@ -1,4 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Site
|
||||||
|
* @subpackage com_oauthserver
|
||||||
|
*
|
||||||
|
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||||
|
* @license MIT; see LICENSE.txt
|
||||||
|
**/
|
||||||
|
|
||||||
namespace Webmasterskaya\Plugin\System\OauthServer\Extension;
|
namespace Webmasterskaya\Plugin\System\OauthServer\Extension;
|
||||||
|
|
||||||
@ -8,54 +15,64 @@ use Joomla\CMS\Router\SiteRouter;
|
|||||||
use Joomla\CMS\Uri\Uri;
|
use Joomla\CMS\Uri\Uri;
|
||||||
use Joomla\Event\SubscriberInterface;
|
use Joomla\Event\SubscriberInterface;
|
||||||
|
|
||||||
|
// phpcs:disable PSR1.Files.SideEffects
|
||||||
|
\defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
// phpcs:enable PSR1.Files.SideEffects
|
||||||
|
|
||||||
class Plugin extends CMSPlugin implements SubscriberInterface
|
class Plugin extends CMSPlugin implements SubscriberInterface
|
||||||
{
|
{
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
{
|
{
|
||||||
return ['onAfterInitialise' => 'attachOauthRouter'];
|
return ['onAfterInitialise' => 'attachOauthRouter'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachOauthRouter(): void
|
/**
|
||||||
{
|
* @return void
|
||||||
/** @var \Joomla\CMS\Application\SiteApplication $app */
|
* @since version
|
||||||
$app = $this->getApplication();
|
*/
|
||||||
|
public function attachOauthRouter(): void
|
||||||
|
{
|
||||||
|
/** @var \Joomla\CMS\Application\SiteApplication $app */
|
||||||
|
$app = $this->getApplication();
|
||||||
|
|
||||||
if (!$app->isClient('site')) {
|
if (!$app->isClient('site'))
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var \Joomla\CMS\Router\SiteRouter $siteRouter */
|
/** @var \Joomla\CMS\Router\SiteRouter $siteRouter */
|
||||||
$siteRouter = Factory::getContainer()->get(SiteRouter::class);
|
$siteRouter = Factory::getContainer()->get(SiteRouter::class);
|
||||||
$siteRouter->attachParseRule([$this, 'parseOauthRoute'], $siteRouter::PROCESS_BEFORE);
|
$siteRouter->attachParseRule([$this, 'parseOauthRoute'], $siteRouter::PROCESS_BEFORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Joomla\CMS\Router\SiteRouter $router
|
* @param \Joomla\CMS\Router\SiteRouter $router
|
||||||
* @param \Joomla\CMS\Uri\Uri $uri
|
* @param \Joomla\CMS\Uri\Uri $uri
|
||||||
* @return void
|
*
|
||||||
* @since version
|
* @return void
|
||||||
*/
|
* @since version
|
||||||
public function parseOauthRoute(SiteRouter &$router, Uri &$uri): void
|
*/
|
||||||
{
|
public function parseOauthRoute(SiteRouter &$router, Uri &$uri): void
|
||||||
$route = trim($uri->getPath(), '/');
|
{
|
||||||
|
$route = trim($uri->getPath(), '/');
|
||||||
|
|
||||||
if (empty($route)) {
|
if (empty($route))
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Переделать на ComponentRouter (пример в Joomla\CMS\Router\SiteRouter::parseSefRoute())
|
if (!str_starts_with($route, 'login/oauth'))
|
||||||
// 1. Зарегистрировать роутер компонента $router->setComponentRouter()
|
{
|
||||||
// 2. Вызвать $router->getComponentRouter($component)
|
return;
|
||||||
if (!str_starts_with($route, 'login/oauth')) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$segments = explode('/', $route);
|
$segments = explode('/', $route);
|
||||||
|
|
||||||
$uri->setVar('option', 'com_oauthserver');
|
$uri->setVar('option', 'com_oauthserver');
|
||||||
$uri->setVar('task', 'login.' . $segments[2]);
|
$uri->setVar('task', 'login.' . $segments[2]);
|
||||||
$uri->setVar('view', 'default');
|
$uri->setVar('view', 'default');
|
||||||
|
|
||||||
$uri->setPath('');
|
$uri->setPath('');
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user