Skip to content

Commit 5e4480d

Browse files
committed
Рефакторинг.
1 parent ab47d0b commit 5e4480d

File tree

7 files changed

+49
-16
lines changed

7 files changed

+49
-16
lines changed

configs/route_config_template.php.tmpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22

33
use Bitrix\Main\Routing\RoutingConfigurator;
4-
use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\RoutesLoader;
5-
use Prokl\BitrixSymfonyRouterBundle\Services\Utils\BitrixRouteConvertor;
64
use Proklung\Symfony\Router\Utils\Loader;
7-
use ProklUng\Module\Boilerplate\Options\ModuleManager;
5+
use Proklung\Symfony\Router\Utils\OptionsManager;
86

97
// init kernel
108
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
@@ -13,8 +11,7 @@ if (!\Bitrix\Main\Loader::includeModule('proklung.symfony.router')) {
1311
return function (RoutingConfigurator $routes) {};
1412
}
1513

16-
$moduleManager = new ModuleManager('proklung.symfony.router');
17-
$phpConfigFile = $moduleManager->get('php_router_config_path');
14+
$phpConfigFile = OptionsManager::option('php_router_config_path');
1815

1916
$routeConvertor = Loader::get($phpConfigFile);
2017

install/admin/symfony_router_index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
use ProklUng\Module\Boilerplate\Module;
44

55
require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php';
6-
7-
// @todo: Здесь - какой-то системный код, читающие данные и всё такое
8-
96
require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php';
107

118
// Странный эффект: на новой версии Битрикса на этой стадии класс модуля не инстанцирован.

lib/RoutesLoader.php renamed to lib/BaseRoutesConfigurator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
use Symfony\Component\Routing\RouterInterface;
2020

2121
/**
22-
* Class RoutesLoader
22+
* Class BaseRoutesConfigurator
2323
* Независимый от контейнера загрузчик роутов.
2424
* @package Proklung\Symfony\Router
2525
*
2626
* @since 24.07.2021
2727
*/
28-
class RoutesLoader
28+
class BaseRoutesConfigurator
2929
{
3030
/**
3131
* @var RouterInterface $router Роутер.
3232
*/
33-
private static $router;
33+
protected static $router;
3434

3535
/**
3636
* @var ResourceCheckerConfigCacheFactory $cacheFactory

lib/BitrixRoutes.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Proklung\Symfony\Router;
4+
5+
use Symfony\Component\Routing\RouterInterface;
6+
7+
/**
8+
* Class BitrixRoutes
9+
* @package Proklung\Symfony\Router
10+
*
11+
* @since 26.07.2021
12+
*/
13+
class BitrixRoutes extends BaseRoutesConfigurator
14+
{
15+
/**
16+
* @var RouterInterface $router Роутер.
17+
*/
18+
protected static $router;
19+
}

lib/SymfonyRoutes.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Proklung\Symfony\Router;
4+
5+
use Symfony\Component\Routing\RouterInterface;
6+
7+
/**
8+
* Class SymfonyRoutes
9+
* @package Proklung\Symfony\Router
10+
*
11+
* @since 26.07.2021
12+
*/
13+
class SymfonyRoutes extends BaseRoutesConfigurator
14+
{
15+
/**
16+
* @var RouterInterface $router Роутер.
17+
*/
18+
protected static $router;
19+
}

lib/Utils/Loader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Proklung\Symfony\Router\Utils;
44

55
use Proklung\Symfony\Router\BitrixInitializerRouter;
6+
use Proklung\Symfony\Router\BitrixRoutes;
67
use Proklung\Symfony\Router\Router;
7-
use Proklung\Symfony\Router\RoutesLoader;
8+
use Proklung\Symfony\Router\SymfonyRoutes;
89

910
/**
1011
* Class Loader
@@ -96,7 +97,7 @@ public static function from(?string $yamlConfig = null, ?string $cachePath = nul
9697
public function loadRouter(?string $yamlConfig = null, ?string $cachePath = null) : ?Router
9798
{
9899
if ($yamlConfig && @file_exists($_SERVER['DOCUMENT_ROOT'] . $yamlConfig)) {
99-
$agnosticRouter = new RoutesLoader(
100+
$agnosticRouter = new SymfonyRoutes(
100101
$_SERVER['DOCUMENT_ROOT'] . $yamlConfig,
101102
$cachePath ? $_SERVER['DOCUMENT_ROOT'] . $cachePath : null,
102103
(bool)$_ENV['DEBUG']
@@ -122,7 +123,7 @@ public function loadRouter(?string $yamlConfig = null, ?string $cachePath = null
122123
public function loadRouterNative(?string $yamlConfig = null, ?string $cachePath = null) : ?BitrixRouteConvertor
123124
{
124125
if ($yamlConfig && @file_exists($_SERVER['DOCUMENT_ROOT'] . $yamlConfig)) {
125-
$agnosticRouter = new RoutesLoader(
126+
$agnosticRouter = new BitrixRoutes(
126127
$_SERVER['DOCUMENT_ROOT'] . $yamlConfig,
127128
$cachePath ? $_SERVER['DOCUMENT_ROOT'] . $cachePath : null,
128129
(bool)$_ENV['DEBUG']

readme.MD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ Loader::includeModule('proklung.symfony.router');
113113

114114
## Прочее
115115

116-
1) Экземпляр `Symfony\Component\Routing\Router` можно получить снаружи так:
116+
1) Экземпляр `Symfony\Component\Routing\Router` (роуты Symfony) можно получить снаружи так:
117117

118118
```php
119-
$router = \Proklung\Symfony\Router\RoutesLoader::getInstance();
119+
$router = \Proklung\Symfony\Router\SymfonyRoutes::getInstance();
120120
```

0 commit comments

Comments
 (0)