In meinem Moduls module.config.php
, ich habe so etwas wie dies:ZF3: Wie zu bestimmten Controller/Aktion auf der Grundlage von Methode und Route?
namespace Application;
return [
//...
// myroute1 will route to IndexController fooAction if the route is matching '/index/foo' but regardless of request method
'myroute1' => [
'type' => Zend\Router\Http\Literal::class,
'options' => [
'route' => '/index/foo',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo',
],
],
],
// myroute2 will route to IndexController fooAction if the route is request method is GET but regardless of requested route
'myroute2' => [
'type' => Zend\Router\Http\Method::class,
'options' => [
'verb' => 'get',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo',
],
],
],
//...
];
Was ich versuche zu erreichen: /index/foo angefordert
- Wenn Route UND angefordert wird durch GET Methode, dann sollte es an weitergeleitet werden. IndexControllerfooAction
- Wenn r out /index/foo angefordert wird, und wird durch POST Methode angefordert, dann sollte es zu Indexcontrollerbar Aktion geleitet wird (merkt es barAction ist hier nicht fooAction)
Wie zu erreichen Das?
Das ist was ich gesucht habe. Aber ich habe bemerkt, dass es erwähnt wird. "Teilstrecken sind nicht dazu gedacht, direkt benutzt zu werden". – evilReiko