public function match(View $view)
{
$viewType = $view->getViewType();
if (!isset($this->matchConfig[$viewType])) {
return null;
}
if (!isset($this->alreadyMatched[$viewType])) {
$this->alreadyMatched[$viewType] = new SplObjectStorage();
}
// If we already matched, just returned the matched value.
if (isset($this->alreadyMatched[$viewType][$view])) {
return $this->alreadyMatched[$viewType][$view];
}
foreach ($this->matchConfig[$viewType] as $configHash) {
$hasMatched = true;
$matcher = null;
foreach ($configHash['match'] as $matcherIdentifier => $value) {
$matcher = $this->getMatcher($matcherIdentifier);
$matcher->setMatchingConfig($value);
if (!$matcher->match($view)) {
$hasMatched = false;
}
}
if ($hasMatched) {
return $this->alreadyMatched[$viewType][$view] = $configHash + array('matcher' => $matcher);
}
}
return $this->alreadyMatched[$viewType][$view] = null;
}