GREAT Martel! We love you!
I'm looking forward to this nice implementation and hope it gets soon into the
incubator.
thx, Philip
Martel Valgoerad wrote:
> Philip Iezzi wrote:
>
>> We could then set up some static routes to make life a bit easier:
>> new Zend_Controller_Router_StaticRoute('logout', array('action' =>
>> 'logout'));
>>
>> Instead of calling an ugly "/index/index/logout" URI, we could call
>> "/logout" and place the logout action directly in
>> /application/controllers/IndexController.php
>> I'd rather prefer some regular expression to write one single static
>> route for all requests not matching the :module/:controller/:action
>> layout, something like:
>>
>> new Zend_Controller_Router_StaticRoute('!(admin|moderator)',
>> array('module' => 'index', 'controller' => 'index', 'action' => '$1'));
>> (totally wrong regex, I know, this is just pseudocode!!)
>
> I'm in the middle of creating new route class called RegexRoute. It will
> be able to accomplish what you're trying to do above. It's constuctor
> signature is:
>
> Zend_Controller_Router_RegexRoute($regex, array $defaults, array $map)
>
> Regex and defaults parameters will be compatible with all other route
> objects with one exception => you will be able to define integer indexed
> defaults in order to enable it to work with regex subpatterns.
>
> There will be a third optional parameter named $map, which will hold
> key-value pairs for mapping subpatterns to named parameters. So to
> achieve what you have given example for, you will have to create the
> route this way:
>
> new Zend_Controller_Router_RegexRoute('!(admin|moderator)',
> array('module' => 'index', 'controller' => 'index'),
> array(1 => 'action')
> );
>
> Or to make it actually work, we have to use conditional matching (or any
> other way to simulate the negative match) because there is no negative
> subpattern matching mechanism in PHP's PCRE:
>
> $route = new
> Zend_Controller_Router_RegexRoute('((?!admin|moderator).+)',
> array('module' => 'index', 'controller' => 'index'),
> array(1 => 'action')
> );
>
> And the code is almost complete and this test already passes with the
> current code:
>
> public function testNegativeMatch()
> {
>
> $route = new Aie_Mvc_LiteRegexRoute('((?!admin|moderator).+)',
> array('module' => 'index', 'controller' => 'index'),
> array(1 => 'action')
> );
>
> $values = $route->match('users');
>
> $this->assertSame(3, count($values));
> $this->assertSame('index', $values['module']);
> $this->assertSame('index', $values['controller']);
> $this->assertSame('users', $values['action']);
> }
>
> I yet have to make assembling work (I guess about 70% work is already
> done) and create a proposal. Then everything will be in the hands of
> Matthew.
>
>> Philip
>