Note that there are some explanatory texts on larger screens.

plurals
  1. POpreDispatch zend framework 2 not working
    primarykey
    data
    text
    <p>i am having problems in understanding preDispatch below is my code </p> <pre><code> public function preDispatch(\Zend\Mvc\MvcEvent $e) { $application = $e-&gt;getApplication(); $serviceManager = $application-&gt;getServiceManager(); $controller = $e-&gt;getTarget(); $route = $controller-&gt;getEvent()-&gt;getRouteMatch(); $hit_controller = $route-&gt;getParam('__CONTROLLER__'); if(strcmp($hit_controller,"Dashboard")==0){ $authService = $serviceManager-&gt;get('Admin\Authentication\Service'); if (!$authService-&gt;hasIdentity()) { $pluginManager = $serviceManager-&gt;get('Zend\Mvc\Controller\PluginManager'); $redirectPlugin = $pluginManager-&gt;get('redirect'); return $redirectPlugin-&gt;toRoute('Admin',array('controller'=&gt;'Admin','action'=&gt;'index')); } } return; } </code></pre> <p>Below are my routes defined in module.config.php</p> <pre><code>return array( 'router' =&gt; array( 'routes' =&gt; array( 'Dashboard' =&gt; array( 'type' =&gt; 'Segment', 'options' =&gt; array( 'route' =&gt; '/Dashboard[/:action][/:id]', 'defaults' =&gt; array( '__NAMESPACE__' =&gt; 'Admin\Controller', 'controller' =&gt; 'Dashboard', 'action' =&gt; 'index', ), ), ), 'Admin' =&gt; array( 'type' =&gt; 'Segment', 'options' =&gt; array( 'route' =&gt; '/Admin[/:action][/:id]', 'defaults' =&gt; array( '__NAMESPACE__' =&gt; 'Admin\Controller', 'controller' =&gt; 'Admin', 'action' =&gt; 'index', ), ), ), ), ), 'controllers' =&gt; array( 'invokables' =&gt; array( 'Admin\Controller\Admin' =&gt; 'Admin\Controller\AdminController', 'Admin\Controller\Dashboard' =&gt; 'Admin\Controller\DashboardController' ), ), 'view_manager' =&gt; array( ), 'template_path_stack' =&gt; array( __DIR__ . '/../view', ), ), ); </code></pre> <p>If i type in the url </p> <pre><code>public/Admin works fine public/Dashboard works fine public/Dashboard/edit works fine public/Dashboard/edit/11 fails </code></pre> <p>and display the contents of edit/11 . I do not understand why the preDispatch doesn't run on Dashboard/edit/11 ?</p> <p>Can some one please throw light and guide in the right direction. Any suggestions/ comments/ hlep are highly regarded. thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload