@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public function indexAction() |
| 22 | 22 | { |
| 23 | 23 | $this->layout(Module::DEFAULT_LAYOUT); |
| 24 | - $view = new ViewModel([]); |
|
| 24 | + $view = new ViewModel([ ]); |
|
| 25 | 25 | $view->setTemplate(Package::FQPN . '/index/index'); |
| 26 | 26 | |
| 27 | 27 | return $view; |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | { |
| 25 | 25 | /** @var array $config */ |
| 26 | 26 | $config = $serviceLocator->get('config'); |
| 27 | - $config = isset($config['router']['routes']) ? $config['router']['routes'] : []; |
|
| 27 | + $config = isset($config[ 'router' ][ 'routes' ]) ? $config[ 'router' ][ 'routes' ] : [ ]; |
|
| 28 | 28 | |
| 29 | 29 | /** @var RouteInterface $router */ |
| 30 | 30 | $router = $serviceLocator->get('router'); |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | foreach (array_keys($routesConfig) as $k) { |
| 49 | 49 | $childRoutes = null; |
| 50 | - if (isset($routesConfig[$k]['child_routes']) && !empty($routesConfig[$k]['child_routes'])) { |
|
| 51 | - $childRoutes = $routesConfig[$k]['child_routes']; |
|
| 52 | - unset($routesConfig[$k]['child_routes']); |
|
| 50 | + if (isset($routesConfig[ $k ][ 'child_routes' ]) && !empty($routesConfig[ $k ][ 'child_routes' ])) { |
|
| 51 | + $childRoutes = $routesConfig[ $k ][ 'child_routes' ]; |
|
| 52 | + unset($routesConfig[ $k ][ 'child_routes' ]); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $routesConfig[$k]['name'] = $k; |
|
| 56 | - $route = $this->processRoute($routesConfig[$k], $parentRoute); |
|
| 57 | - if (!isset($routesConfig[$k]['may_terminate']) || false !== $routesConfig[$k]['may_terminate']) { |
|
| 55 | + $routesConfig[ $k ][ 'name' ] = $k; |
|
| 56 | + $route = $this->processRoute($routesConfig[ $k ], $parentRoute); |
|
| 57 | + if (!isset($routesConfig[ $k ][ 'may_terminate' ]) || false !== $routesConfig[ $k ][ 'may_terminate' ]) { |
|
| 58 | 58 | $routeCollection->addRoute($route); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function processRoute(array $routeConfig, Route $parentRoute = null) |
| 76 | 76 | { |
| 77 | - $name = $routeConfig['name']; |
|
| 78 | - $url = isset($routeConfig['options']['route']) ? $routeConfig['options']['route'] : ''; |
|
| 79 | - $controller = isset($routeConfig['options']['defaults']['controller']) |
|
| 80 | - ? $routeConfig['options']['defaults']['controller'] : null; |
|
| 81 | - $action = isset($routeConfig['options']['defaults']['action']) |
|
| 82 | - ? $routeConfig['options']['defaults']['action'] : null; |
|
| 77 | + $name = $routeConfig[ 'name' ]; |
|
| 78 | + $url = isset($routeConfig[ 'options' ][ 'route' ]) ? $routeConfig[ 'options' ][ 'route' ] : ''; |
|
| 79 | + $controller = isset($routeConfig[ 'options' ][ 'defaults' ][ 'controller' ]) |
|
| 80 | + ? $routeConfig[ 'options' ][ 'defaults' ][ 'controller' ] : null; |
|
| 81 | + $action = isset($routeConfig[ 'options' ][ 'defaults' ][ 'action' ]) |
|
| 82 | + ? $routeConfig[ 'options' ][ 'defaults' ][ 'action' ] : null; |
|
| 83 | 83 | |
| 84 | 84 | if (null !== $parentRoute) { |
| 85 | 85 | $name = $parentRoute->getName() . '/' . $name; |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $data = $this->params()->fromQuery(); |
| 84 | 84 | $route = null; |
| 85 | - if (isset($data['method']) && !empty($data['method']) && isset($data['url']) && !empty($data['url'])) { |
|
| 86 | - if (null !== ($routeName = $this->routeMatcher->match($data['method'], $data['url']))) { |
|
| 85 | + if (isset($data[ 'method' ]) && !empty($data[ 'method' ]) && isset($data[ 'url' ]) && !empty($data[ 'url' ])) { |
|
| 86 | + if (null !== ($routeName = $this->routeMatcher->match($data[ 'method' ], $data[ 'url' ]))) { |
|
| 87 | 87 | $route = $this->routeCollection->getRoute($routeName); |
| 88 | 88 | $route = [ |
| 89 | 89 | 'name' => $route->getName(), |
@@ -94,6 +94,6 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - return new JsonModel(['requestedRouteData' => $data, 'routeMatch' => $route]); |
|
| 97 | + return new JsonModel([ 'requestedRouteData' => $data, 'routeMatch' => $route ]); |
|
| 98 | 98 | } |
| 99 | 99 | } |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @param array $routes |
| 22 | 22 | */ |
| 23 | - public function __construct(array $routes = []) |
|
| 23 | + public function __construct(array $routes = [ ]) |
|
| 24 | 24 | { |
| 25 | - $this->routes = []; |
|
| 25 | + $this->routes = [ ]; |
|
| 26 | 26 | foreach ($routes as $route) { |
| 27 | 27 | $this->addRoute($route); |
| 28 | 28 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function addRoute(Route $route) |
| 35 | 35 | { |
| 36 | - $this->routes[$route->getName()] = $route; |
|
| 36 | + $this->routes[ $route->getName() ] = $route; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getRoute($routeName) |
| 45 | 45 | { |
| 46 | - if (!isset($this->routes[$routeName])) { |
|
| 46 | + if (!isset($this->routes[ $routeName ])) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return $this->routes[$routeName]; |
|
| 50 | + return $this->routes[ $routeName ]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -44,10 +44,10 @@ |
||
| 44 | 44 | $fileName = sprintf('%s/%s_routes_%s.csv', $this->outputDir, Package::NAME, $datetime->format('Ymd-His.u')); |
| 45 | 45 | |
| 46 | 46 | $fp = fopen($fileName, 'w'); |
| 47 | - fputcsv($fp, ['Route name', 'URL', 'Controller', 'Action']); |
|
| 47 | + fputcsv($fp, [ 'Route name', 'URL', 'Controller', 'Action' ]); |
|
| 48 | 48 | foreach ($this->routeCollection->getRoutes() as $route) { |
| 49 | 49 | /* @var Route $route */ |
| 50 | - fputcsv($fp, [$route->getName(), $route->getUrl(), $route->getController(), $route->getAction()]); |
|
| 50 | + fputcsv($fp, [ $route->getName(), $route->getUrl(), $route->getController(), $route->getAction() ]); |
|
| 51 | 51 | } |
| 52 | 52 | fclose($fp); |
| 53 | 53 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $currentRouteName = $this->getCurrentRouteName($e->getApplication()->getServiceManager()); |
| 65 | - $e->getViewModel()->setVariables(['__currentRouteName' => $currentRouteName]); |
|
| 65 | + $e->getViewModel()->setVariables([ '__currentRouteName' => $currentRouteName ]); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | 'zfdebug routes export' => 'Exports all routes in CSV format', |
| 91 | 91 | 'zfdebug routes list' => 'Lists all routes', |
| 92 | 92 | 'zfdebug routes match [METHOD] [URL]' => 'Matches a URL to a Route', |
| 93 | - ['Examples:'], |
|
| 94 | - ['$ zfdebug routes export', ''], |
|
| 95 | - ['$ zfdebug routes list', ''], |
|
| 96 | - ['$ zfdebug routes match GET /users/123', ''], |
|
| 97 | - ['$ zfdebug routes match POST /login', ''], |
|
| 93 | + [ 'Examples:' ], |
|
| 94 | + [ '$ zfdebug routes export', '' ], |
|
| 95 | + [ '$ zfdebug routes list', '' ], |
|
| 96 | + [ '$ zfdebug routes match GET /users/123', '' ], |
|
| 97 | + [ '$ zfdebug routes match POST /login', '' ], |
|
| 98 | 98 | ]; |
| 99 | 99 | } |
| 100 | 100 | |