現在、Symfony2 でルーティング オプションを設定しようとしているので、にルーティングし/cms
ます/cms/role/view
。ただし、デフォルトの受け渡しは正しく機能していないようです。
/src/MyProject/CMSBundle/Resources/config/routing.yml
MyProjectCMS_specific:
pattern: /cms/{page}/{option}
defaults: { _controller: MyProjectCMSBundle:Main:index, page: role, option: view }
requirements:
_method: GET
/src/MyProject/CMSBundle/Controller/MainController.php
<?php
namespace MyProject\CMSBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class MainController extends Controller
{
public function indexAction($page, $option)
{
$response = null;
/* Switch statement that determines the page to be loaded. */
return $response;
}
}
?>
問題は、「localhost/app_dev.php/cms」にアクセスしようとすると、次のエラーが表示されることです。
Controller "MyProject\CMSBundle\Controller\MainController::indexAction()" requires that you provide a value for the "$page" argument (because there is no default value or because there is a non optional argument after this one).
500 Internal Server Error - RuntimeException
ただし、localhost/app_dev.php/cms/role
またはにアクセスしようとするlocalhost/app_dev.php/cms/role/view
と、正しいページが表示されます。にデフォルト ルートを追加しようとしました/cms
が、それでも同じエラーが発生します。これはどのように可能で、どうすれば修正できますか?
前もって感謝します。