40 lines
792 B
PHP
40 lines
792 B
PHP
<?php
|
|
|
|
namespace CrocWork\Zappy\Routing;
|
|
|
|
class RouteGroup
|
|
{
|
|
use IsRepository;
|
|
|
|
/**
|
|
* @var callable Callback to call to actually register the routes.
|
|
*/
|
|
protected $callback;
|
|
|
|
public function __construct(string $pattern, callable $callback)
|
|
{
|
|
$this->basePattern = $pattern; //Group pattern is used as base pattern for all routes in group.
|
|
$this->callback = $callback;
|
|
$this->routes = [];
|
|
}
|
|
|
|
public function __invoke(): void
|
|
{
|
|
($this->callback)($this);
|
|
}
|
|
|
|
public function getPattern(): string
|
|
{
|
|
return $this->basePattern;
|
|
}
|
|
|
|
public function getCallback(): callable
|
|
{
|
|
return $this->callback;
|
|
}
|
|
|
|
public function getRoutes(): array
|
|
{
|
|
return $this->routes;
|
|
}
|
|
} |