12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php namespace System\Routing;
- class Finder {
-
- public static $names = array();
-
- public static function find($name, $routes)
- {
- if (array_key_exists($name, static::$names))
- {
- return static::$names[$name];
- }
- $arrayIterator = new \RecursiveArrayIterator($routes);
- $recursiveIterator = new \RecursiveIteratorIterator($arrayIterator);
-
-
- foreach ($recursiveIterator as $iterator)
- {
- $route = $recursiveIterator->getSubIterator();
- if (isset($route['name']) and $route['name'] == $name)
- {
- return static::$names[$name] = array($arrayIterator->key() => iterator_to_array($route));
- }
- }
- }
- }
|