子でオプションではないルートのオプションの制約に問題があります。私のルーティング構造は次のとおりです。
'profile' => [
'type' => 'segment',
'options' => [
'route' => '/profile[/:id]',
'constraints' => ['id' => '[0-9]*'],
'defaults' => [
'controller' => 'User\Controller\User',
'action' => 'profile'
]
],
'may_terminate' => true,
'child_routes' => [
'sessions' => [
'type' => 'literal',
'options' => [
'route' => '/sessions',
'defaults' => ['action' => 'sessions']
]
]
]
]
私の考えでは、次のルートを教えてください。
/profile-動作します/profile/123-動作します/profile/sessions-動作しません/profile/123/sessions-動作します
URLビューヘルパーでルート3を使用すると、次のエラーが発生します。
$this->url('profile/sessions');
Zend\Mvc\Router\Exception\InvalidArgumentException:パラメータ「id」がありません
私はもともと[0-9]+制約として持っていましたが、それをオプション(*)にすることは役に立たなかったようです。誰かが以前にこの事件を経験したことがありますか?