-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
017b805
commit dacaa09
Showing
5 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* ZfDebugModule. Console commands and other utilities for debugging ZF2 apps. | ||
* | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @copyright 2016 Vítor Brandão <vitor@noiselabs.org> | ||
*/ | ||
|
||
namespace Noiselabs\ZfDebugModule\Factory\Util; | ||
|
||
use Noiselabs\ZfDebugModule\Util\RoutesInspector; | ||
use Zend\Mvc\Router\RouteInterface; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class RoutesInspectorFactory implements FactoryInterface | ||
{ | ||
const SERVICE_NAME = RoutesInspector::class; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
/** @var array $config */ | ||
$config = $serviceLocator->get('config'); | ||
$config = isset($config['router']['routes']) ? $config['router']['routes'] : []; | ||
|
||
/** @var RouteInterface $router */ | ||
$router = $serviceLocator->get('router'); | ||
|
||
return new RoutesInspector($router, $config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* ZfDebugModule. Console commands and other utilities for debugging ZF2 apps. | ||
* | ||
* @license http://www.opensource.org/licenses/mit-license.html MIT License | ||
* @copyright 2016 Vítor Brandão <vitor@noiselabs.org> | ||
*/ | ||
|
||
namespace Noiselabs\ZfDebugModule\Util; | ||
|
||
use Zend\Mvc\Router\RouteInterface; | ||
use Zend\Mvc\Router\SimpleRouteStack; | ||
|
||
class RoutesInspector | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var RouteInterface | ||
*/ | ||
private $router; | ||
|
||
/** | ||
* RoutesInspector constructor. | ||
* | ||
* @param RouteInterface $router | ||
* @param array $config | ||
*/ | ||
public function __construct(RouteInterface $router, array $config) | ||
{ | ||
$this->router = $router; | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @return array|\Traversable | ||
*/ | ||
public function getRoutes() | ||
{ | ||
if ($this->router instanceof SimpleRouteStack) { | ||
/** @var SimpleRouteStack $router */ | ||
$router = $this->router; | ||
|
||
return $router->getRoutes(); | ||
} | ||
|
||
return []; | ||
} | ||
} |