난 그냥 당신이 잘못 아니에요
틀렸다면 정정 해줘, 경로를 설정하는 /files[/action[/:fileId]]
에 경로를 변경할 수 있습니다, 그것은 유효한 경로가 될 것입니다.
내가 경로 정의를 변경해야 할 것이 있습니까? 당신이 선택 경로 PARAM로 fileId
을 추가하는 경우
은 당신이 설정되어 있는지 확인하기 위해 downloadAction()
내 일부 수동 검사를 수행해야합니다.
다른 해결책은 경로를 자식으로 분리하는 것입니다. 이렇게하면 각 경로에 올바른 매개 변수가 없으면 일치하지 않게됩니다.
'files' => array(
'type' => 'Segment',
'options' => array(
'route' => '/files',
'defaults' => array(
'controller' => 'Application\Controller\Files',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'download' => array(
'type' => 'Segment',
'options' => array(
'route' => '/download/:fileId',
'defaults' => array(
'action' => 'download',
),
'constraints' => array(
'fileId' => '[a-zA-Z0-9]+',
),
),
),
'upload' => array(
'type' => 'Literal',
'options' => array(
'route' => '/upload',
'defaults' => array(
'action' => 'upload',
),
),
),
),
),
어떻게 내가) 가장 쉬운 방법은 경로에서 매개 변수를 가져 use the Zend\Mvc\Controller\Plugin\Params
controller plugin에있을 것 downloadAction
내부 fileId
에 액세스 않습니다. 아주 명확하고 완전한 답변에 대한 경로에서
// FilesController::downloadAction()
$fileId = $this->params('fileId');
또는 특별히
// FilesController::downloadAction()
$fileId = $this->params()->fromRoute('fileId');
감사합니다. – Bogdan