Skip to content

Commit

Permalink
Доработки
Browse files Browse the repository at this point in the history
  • Loading branch information
ProklUng committed Jul 26, 2021
1 parent 59ca757 commit 82bc0f7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 Роутер.
Expand Down
19 changes: 19 additions & 0 deletions Services/Agnostic/BitrixRoutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Prokl\BitrixSymfonyRouterBundle\Services\Agnostic;

use Symfony\Component\Routing\RouterInterface;

/**
* Class BitrixRoutes
* @package Prokl\BitrixSymfonyRouterBundle\Services\Agnostic
*
* @since 26.07.2021
*/
class BitrixRoutes extends BaseRoutesConfigurator
{
/**
* @var RouterInterface $router Роутер.
*/
protected static $router;
}
19 changes: 19 additions & 0 deletions Services/Agnostic/SymfonyRoutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Prokl\BitrixSymfonyRouterBundle\Services\Agnostic;

use Symfony\Component\Routing\RouterInterface;

/**
* Class SymfonyRoutes
* @package Prokl\BitrixSymfonyRouterBundle\Services\Agnostic
*
* @since 26.07.2021
*/
class SymfonyRoutes extends BaseRoutesConfigurator
{
/**
* @var RouterInterface $router Роутер.
*/
protected static $router;
}
12 changes: 6 additions & 6 deletions Tests/Cases/AgnosticRoutesLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Prokl\BitrixSymfonyRouterBundle\Tests\Cases;

use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\RoutesConfigurator;
use Prokl\BitrixSymfonyRouterBundle\Services\Agnostic\BaseRoutesConfigurator;
use Prokl\TestingTools\Base\BaseTestCase;
use Symfony\Component\Filesystem\Filesystem;

/**
* Class AgnosticRoutesLoaderTest
* @package Prokl\BitrixSymfonyRouterBundle\Tests
* @coversDefaultClass RoutesConfigurator
* @coversDefaultClass BaseRoutesConfigurator
*
* @since 24.07.2021
*/
class AgnosticRoutesLoaderTest extends BaseTestCase
{
/**
* @var RoutesConfigurator $obTestObject Тестируемый объект.
* @var BaseRoutesConfigurator $obTestObject Тестируемый объект.
*/
protected $obTestObject;

Expand Down Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void

$this->filesystem = new Filesystem();

$this->obTestObject = new RoutesConfigurator(
$this->obTestObject = new BaseRoutesConfigurator(
$this->routesConfig,
null,
true
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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'] // Режим отладки или нет
Expand All @@ -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();
```

0 comments on commit 82bc0f7

Please sign in to comment.