Skip to content

Commit ab47d0b

Browse files
committed
Оптимизации.
1 parent dbd9756 commit ab47d0b

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

lib/Utils/BitrixRouteConvertor.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Bitrix\Main\Routing\RoutingConfigurator;
88
use LogicException;
99
use RuntimeException;
10-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
1110
use Symfony\Component\Routing\Route;
1211
use Symfony\Component\Routing\RouteCollection;
1312

@@ -19,8 +18,6 @@
1918
*/
2019
class BitrixRouteConvertor
2120
{
22-
use ContainerAwareTrait;
23-
2421
/**
2522
* @var RouteCollection $routeCollection Коллекция роутов.
2623
*/
@@ -91,24 +88,14 @@ public function convertRoute(string $name, Route $route, RoutingConfigurator $ro
9188
);
9289
}
9390

94-
// Достаю из контейнера, только если он задан.
95-
if ($this->container !== null) {
96-
if (!$this->container->has($controller[0])) {
97-
throw new RuntimeException(
98-
sprintf('Controller %s not registered as service', $controller[0])
99-
);
100-
}
101-
102-
$service = $this->container->get($controller[0]);
103-
} else {
104-
if (!class_exists($controller[0])) {
105-
throw new RuntimeException(
106-
sprintf('Class %s not exist.', $controller[0])
107-
);
108-
}
109-
$service = new $controller[0];
91+
if (!class_exists($controller[0])) {
92+
throw new RuntimeException(
93+
sprintf('Class %s not exist.', $controller[0])
94+
);
11095
}
11196

97+
$service = new $controller[0];
98+
11299
$processedRoute = $routes->any($path, [$service, $controller[1]]);
113100

114101
$processedRoute = $processedRoute->methods($methods)

0 commit comments

Comments
 (0)