简体   繁体   中英

Zend Framework Routing Issue

I have a module with the following in the module.config.php

<?php
return array(
        'controllers' => array(
                'invokables' => array(
                        'BlindQC\Controller\BlindQC' => 'BlindQC\Controller\BlindQCController',
                ),
        ),
        // The following section is new and should be added to your file
        'router' => array(
                'routes' => array(
                        'blinqc' => array(
                                'type' => 'Segment',
                                'options' => array(
                                        'route' => '/blindqc/jobs[/:user_id]',
                                        'defaults' => array(
                                                '__NAMESPACE__' => 'BlindQC\Controller',
                                                'controller' => 'BlindQC',
                                                'action' => 'index',
                                        ),
                                ),
                        ),
                ),
        ),
        'view_manager' => array(
                'template_path_stack' => array(
                        'blindqc' => __DIR__ . '/../view',
                ),
        ),
);

This allows me to go to www.example.com/blindqc/jobs or www.example.com/blindqc/jobs/123456

On this page I have a search box where the user can enter a user_id , which upon hitting Search should redirect them to the url followed by the entered user_id . So if they type 999999 it should take them to www.example.com/blindqc/jobs/999999 . I seem to be having an issue using routes to get them there.

I've tried:

return $this->redirect()->toRoute("blindqc/jobs/", array("user_id" => $userId)); 

But I get an error:

Route with name "blindqc" not found

What am I doing incorrectly? As far as I can tell the route is defined correctly?

The third line in the snippet below reads blinqc whereas it ought to be blindqc .

'router' => array(
    'routes' => array(
        'blinqc' => array(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM