Skip to content

Commit

Permalink
refactoring for V3
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandar Varnicic committed Oct 12, 2016
1 parent 1b9a537 commit bcd0fb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "tasmaniski/zf2-current-route",
"name": "tasmaniski/zend-current-route",
"description": "View Helper for reading current route info: Controller, Action, Module name",
"type": "library",
"keywords": ["zf2", "view", "helper", "route"],
"keywords": ["zend framework", "view", "helper", "route"],
"homepage": "https://github.com/tasmaniski",
"authors": [
{
Expand All @@ -11,8 +11,8 @@
}
],
"require": {
"php": ">=5.3",
"zendframework/zendframework": "2.5.*"
"php": ">=5.6",
"zendframework/zend-mvc": "^3.0"
},
"autoload": {
"psr-0": {
Expand Down
14 changes: 7 additions & 7 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

return array(
'view_helpers' => array(
'factories' => array(
'currentRoute' => '\CurrentRoute\Factory\View\Helper\CurrentRouteFactory'
)
)
);
return [
'view_helpers' => [
'factories' => [
'currentRoute' => CurrentRoute\Factory\View\Helper\CurrentRouteFactory::class
]
]
];
19 changes: 7 additions & 12 deletions src/CurrentRoute/Factory/View/Helper/CurrentRouteFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@

namespace CurrentRoute\Factory\View\Helper;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Interop\Container\ContainerInterface;
use Zend\Mvc\Router\Http\RouteMatch;
use \CurrentRoute\View\Helper\CurrentRoute;
use CurrentRoute\View\Helper\CurrentRoute;

class CurrentRouteFactory implements FactoryInterface
class CurrentRouteFactory
{
/**
* @param ServiceLocatorInterface $serviceLocator
*
* @return CurrentRoute
*/
public function createService(ServiceLocatorInterface $serviceLocator)

public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$routeMatch = $serviceLocator->getServiceLocator()->get('Application')->getMvcEvent()->getRouteMatch();
$routeMatch = $container->get('Application')->getMvcEvent()->getRouteMatch();
$controller = $action = $route = $module = '';

if($routeMatch) {
if($routeMatch){
$controller = $routeMatch->getParam('controller');
$action = $routeMatch->getParam('action');
$module = $routeMatch->getParam('__NAMESPACE__');
Expand Down
15 changes: 8 additions & 7 deletions src/CurrentRoute/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace CurrentRoute;

class Module {
class Module
{

public function getConfig()
{
Expand All @@ -11,13 +12,13 @@ public function getConfig()

public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__,
),
),
);
],
],
];
}

}

0 comments on commit bcd0fb4

Please sign in to comment.