Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
msarca committed Feb 3, 2018
1 parent 09f4d70 commit 69a26ba
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Router
/** @var array */
protected $global;

/** @var SplObjectStorage */
protected $store;
/** @var array */
protected $compacted = [];

/** @var Context|null */
protected $context;
Expand All @@ -60,7 +60,6 @@ public function __construct(
$this->dispatcher = $dispatcher;
$this->filters = $filters;
$this->global = $global;
$this->store = new SplObjectStorage();
}

/**
Expand Down Expand Up @@ -117,17 +116,20 @@ public function getContext(): Context
return $this->context;
}


/**
* @param Route $route
* @return CompactRoute
*/
public function compact(Route $route)
{
if (!isset($this->store[$route])) {
return $this->store[$route] = new CompactRoute($route, $this->getContext(), $this->getGlobalValues());
$cid = spl_object_hash($this->context);
$rid = spl_object_hash($route);

if (!isset($this->compacted[$cid][$rid])) {
return $this->compacted[$cid][$rid] = new CompactRoute($route, $this->context, $this->getGlobalValues());
}
return $this->store[$route];

return $this->compacted[$cid][$rid];
}

/**
Expand Down

0 comments on commit 69a26ba

Please sign in to comment.