public function __construct(RouteParser $routeParser, InvokerInterface $invoker, EventDispatcherInterface $eventDispatcher = null, $cachePath = null)
{
$this->routes = new \SplObjectStorage();
$this->invoker = $invoker;
$this->eventDispatcher = $eventDispatcher;
if ($cachePath) {
$this->cachePath = $cachePath;
if (file_exists($cachePath)) {
Route::setRouter($this);
$this->dispatchData = (require $cachePath);
return;
}
}
$this->routeCollector = new RouteCollector($routeParser, new DataGenerator());
}