This repository was archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoutesExtractor.php
More file actions
64 lines (55 loc) · 1.46 KB
/
Copy pathRoutesExtractor.php
File metadata and controls
64 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
* This file is part of the 4devs Export Routing package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FDevs\ExportRouting;
use FDevs\ExportRouting\Extractor\ExposedInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;
class RoutesExtractor implements RoutesExtractorInterface
{
/**
* @var RouterInterface
*/
private $router;
/**
* @var ExposedInterface
*/
private $exposed;
/**
* RoutesExtractor constructor.
*
* @param RouterInterface $router
* @param ExposedInterface $exposed
*/
public function __construct(RouterInterface $router, ExposedInterface $exposed)
{
$this->router = $router;
$this->exposed = $exposed;
}
/**
* {@inheritdoc}
*/
public function getRoutes(): RouteCollection
{
$routes = new RouteCollection();
$collection = $this->router->getRouteCollection();
foreach ($collection->all() as $name => $item) {
if (true === $this->exposed->isRouteExposed($item, $name)) {
$routes->add($name, $item);
}
}
return $routes;
}
/**
* {@inheritdoc}
*/
public function getContext(): RequestContext
{
return $this->router->getContext();
}
}