From 82bc0f7ff7c8f8be1b4413e6f79a83e65966789e Mon Sep 17 00:00:00 2001 From: ProklUng Date: Mon, 26 Jul 2021 08:42:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...gurator.php => BaseRoutesConfigurator.php} | 4 ++-- Services/Agnostic/BitrixRoutes.php | 19 +++++++++++++++++++ Services/Agnostic/SymfonyRoutes.php | 19 +++++++++++++++++++ Tests/Cases/AgnosticRoutesLoaderTest.php | 12 ++++++------ readme.MD | 12 ++++++------ 5 files changed, 52 insertions(+), 14 deletions(-) rename Services/Agnostic/{RoutesConfigurator.php => BaseRoutesConfigurator.php} (98%) create mode 100644 Services/Agnostic/BitrixRoutes.php create mode 100644 Services/Agnostic/SymfonyRoutes.php diff --git a/Services/Agnostic/RoutesConfigurator.php b/Services/Agnostic/BaseRoutesConfigurator.php similarity index 98% rename from Services/Agnostic/RoutesConfigurator.php rename to Services/Agnostic/BaseRoutesConfigurator.php index 19a9751..e131140 100644 --- a/Services/Agnostic/RoutesConfigurator.php +++ b/Services/Agnostic/BaseRoutesConfigurator.php @@ -19,13 +19,13 @@ use Symfony\Component\Routing\RouterInterface; /** - * Class RoutesConfigurator + * Class BaseRoutesConfigurator * Независимый от контейнера загрузчик роутов. * @package Prokl\BitrixSymfonyRouterBundle\Services\Agnostic * * @since 24.07.2021 */ -class RoutesConfigurator +class BaseRoutesConfigurator { /** * @var RouterInterface $router Роутер. diff --git a/Services/Agnostic/BitrixRoutes.php b/Services/Agnostic/BitrixRoutes.php new file mode 100644 index 0000000..6109cbb --- /dev/null +++ b/Services/Agnostic/BitrixRoutes.php @@ -0,0 +1,19 @@ +filesystem = new Filesystem(); - $this->obTestObject = new RoutesConfigurator( + $this->obTestObject = new BaseRoutesConfigurator( $this->routesConfig, null, true @@ -85,7 +85,7 @@ public function testGetRoutes() : void */ public function testCaching() : void { - $this->obTestObject = new RoutesConfigurator( + $this->obTestObject = new BaseRoutesConfigurator( $this->routesConfig, $this->cacheDir, true @@ -103,7 +103,7 @@ public function testCaching() : void */ public function testPurgeCache(): void { - $this->obTestObject = new RoutesConfigurator( + $this->obTestObject = new BaseRoutesConfigurator( $this->routesConfig, $this->cacheDir, true diff --git a/readme.MD b/readme.MD index c84acea..a198e80 100644 --- a/readme.MD +++ b/readme.MD @@ -37,14 +37,14 @@ ```php use Prokl\ServiceProvider\ServiceProvider; use Bitrix\Main\Routing\Controllers\PublicPageController; -use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\RoutesConfigurator; +use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\BaseRoutesConfigurator; use Prokl\BitrixSymfonyRouterBundle\Services\Utils\BitrixRouteConvertor; use Bitrix\Main\Routing\RoutingConfigurator; // Не обязательно. Смотри ниже. $container = ServiceProvider::instance(); -$agnosticRouter = new RoutesConfigurator( +$agnosticRouter = new BaseRoutesConfigurator( $_SERVER['DOCUMENT_ROOT'] . '/local/configs/bitrix_routes.yaml', // Конфиг роутов $_SERVER['DOCUMENT_ROOT'] . '/bitrix/cache/routes', // Кэш; если null - без кэширования. $_ENV['DEBUG'] @@ -119,11 +119,11 @@ public_page: `init.php`: ```php -use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\RoutesConfigurator; +use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\BaseRoutesConfigurator; use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\Router; use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\BitrixInitializerRouter; -$agnosticRouter = new RoutesConfigurator( +$agnosticRouter = new BaseRoutesConfigurator( $_SERVER['DOCUMENT_ROOT'] . '/local/configs/standalone_routes.yaml', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/cache/routes_agnostic', // Кэш; если null - без кэширования. $_ENV['DEBUG'] // Режим отладки или нет @@ -141,8 +141,8 @@ $agnosticRouterInstance = new Router( ## Прочее -1) Экземпляр `Symfony\Component\Routing\Router` можно получить снаружи так: +1) Экземпляр `Symfony\Component\Routing\Router` (роуты Symfony) можно получить снаружи так: ```php -$router = \Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\RoutesConfigurator::getInstance(); +$router = \Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\SymfonyRoutes::getInstance(); ``` \ No newline at end of file