<?php
class Route {
public function __construct
(array $route) {
$this->name = key($route); $this->path = $route['path'];
$this->controller = $route['controller'];
$this->action = $route['action'];
}
}
(
'path' => '/',
'controller' => 'IndexController',
'action' => 'indexAction'
),
(
'path' => '/hello',
'controller' => 'HelloController',
'action' => 'helloAction'
)
);
foreach ($routes as $key => $val):
$routeObj = new Route($routes[$key]);
$newRouteObjs[$key] = $routeObj;
endforeach;
echo '<pre>', print_r($newRouteObjs, true), '</pre>';
PD9waHAKY2xhc3MgUm91dGUgewoKcHVibGljIGZ1bmN0aW9uIF9fY29uc3RydWN0KGFycmF5ICRyb3V0ZSkKCXsKCSAgICAkdGhpcy0+bmFtZSA9IGtleSgkcm91dGUpOwoJICAgICR0aGlzLT5wYXRoID0gJHJvdXRlWydwYXRoJ107CgkgICAgJHRoaXMtPmNvbnRyb2xsZXIgPSAkcm91dGVbJ2NvbnRyb2xsZXInXTsKCSAgICAkdGhpcy0+YWN0aW9uID0gJHJvdXRlWydhY3Rpb24nXTsKCgl9Cn0KJHJvdXRlcyA9IGFycmF5KAogICAgICAgICAgICAgICdkZWZhdWx0X3JvdXRlJyA9PiBhcnJheQogICAgICAgICAgICAgICgKICAgICAgICAgICAgICAgICAgJ3BhdGgnID0+ICcvJywKICAgICAgICAgICAgICAgICAgJ2NvbnRyb2xsZXInID0+ICdJbmRleENvbnRyb2xsZXInLAogICAgICAgICAgICAgICAgICAnYWN0aW9uJyA9PiAnaW5kZXhBY3Rpb24nCiAgICAgICAgCSAgKSwKICAgIAkJICAnaGVsbG9fcm91dGUnID0+IGFycmF5CgkJICAgICAgKAkKICAgICAgICAJICAJJ3BhdGgnID0+ICcvaGVsbG8nLAogICAgICAgICAgICAgIAknY29udHJvbGxlcicgPT4gJ0hlbGxvQ29udHJvbGxlcicsCiAgICAgICAgICAgICAgCSdhY3Rpb24nID0+ICdoZWxsb0FjdGlvbicKICAgICAgICAJICApCik7CmZvcmVhY2ggKCRyb3V0ZXMgYXMgJGtleSA9PiAkdmFsKToKCSRyb3V0ZU9iaiA9IG5ldyBSb3V0ZSgkcm91dGVzWyRrZXldKTsKCiAgICAkbmV3Um91dGVPYmpzWyRrZXldID0gJHJvdXRlT2JqOwplbmRmb3JlYWNoOwplY2hvICc8cHJlPicsIHByaW50X3IoJG5ld1JvdXRlT2JqcywgdHJ1ZSksICc8L3ByZT4nOwo=