| 1 | <?php |
||
| 5 | class RouteGroup implements RouteCollectionInterface |
||
| 6 | { |
||
| 7 | use RouteCollectionMapTrait; |
||
| 8 | use RouteConditionTrait; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var callable |
||
| 12 | */ |
||
| 13 | protected $callback; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var \League\Route\RouteCollectionInterface |
||
| 17 | */ |
||
| 18 | protected $collection; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $prefix; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Constructor. |
||
| 27 | * |
||
| 28 | * @param string $prefix |
||
| 29 | * @param callable $callback |
||
| 30 | * @param \League\Route\RouteCollection $collection |
||
| 31 | */ |
||
| 32 | 3 | public function __construct($prefix, callable $callback, RouteCollectionInterface $collection) |
|
| 33 | { |
||
| 34 | 3 | $this->callback = $callback; |
|
| 35 | 3 | $this->collection = $collection; |
|
| 36 | 3 | $this->prefix = sprintf('/%s', ltrim($prefix, '/')); |
|
| 37 | 3 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Process the group and ensure routes are added to the collection. |
||
| 41 | * |
||
| 42 | * @return void |
||
| 43 | */ |
||
| 44 | 3 | public function __invoke() |
|
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | 3 | public function map($method, $path, $handler) |
|
| 69 | } |
||
| 70 |