0
が存在するかどうかを確認する方法:ZF2 - 子供を持つルートは、このルートを考える
'country' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/1country',
'defaults' => array(
'controller' => 'Index',
'action' => 'country',
'country_id' => '5',
),
),
'may_terminate' => true,
'child_routes' => array(
'city' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/1city',
'defaults' => array(
'controller' => 'Index',
'action' => 'city',
'city_id' => '4',
),
),
),
),
),
私がしなければ:
$this->getServiceLocator()->get('Router')->hasRoute('country'); //true
$this->getServiceLocator()->get('Router')->hasRoute('country/city'); //false
を両方に該当する必要がありますが...任意のアイデア?
なぜそのような行動を必要としますか? – newage
は説明が複雑ですが、基本的には最適化されたルートがあり、最適化されたルートはありません。存在していれば、最適化されたSEOルートには最適化されたルートはリダイレクトされません。その親ルート上でhasRouteを実行します。 – peterpeterson