Chaining Routes with Zend Framework

I am trying to implement a route chain for the admin panel on the Zend Framework site I'm working on. I use the following configuration file in the hope that the route "admin" will be routed using "/ admin" and that the route "adminLogin" is routed using "/ admin / login".

<?xml version="1.0" encoding="UTF-8"?>
<routes>
    <admin>
        <route>admin</route>
        <defaults>
            <module>admin</module>
            <controller>index</controller>
            <action>index</action>
        </defaults>
        <chains>
            <adminLogin>
                <route>login</route>
                <defaults>
                    <module>admin</module>
                    <controller>login</controller>
                    <action>index</action>
                </defaults>
            </adminLogin>
        </chains>
    </admin>
</routes>

However, only "adminLogin" works with this configuration. The route "admin" is directed to the module / controller / action by default.

I think I should skip something, how the chain works. Any feedback was greatly appreciated

+3
source share
3

( admin) . , .

, :

<chains>
    <index type="Zend_Controller_Router_Route_Static">
        <route></route>
        <defaults module="admin" controller="index" action="index" />
    </index>
    <login>
        <route>login</route>
        <defaults>
                <module>admin</module>
                <controller>login</controller>
                <action>index</action>
        </defaults>
    </login>
</chains>

chain .

, , , , - , admin-adminLogin. login.

+1

This is the misuse of chains.

Just declare a route for / admin and another for / admin / login. Chains are more useful if you use multiple route classes to determine the resolution of a single route (for example, hostname and path).

-2
source

Source: https://habr.com/ru/post/1713906/


All Articles