EC-CUBE4ではルーティングはコントローラーに書いていきます。
以下は商品カテゴリーのルーティングサンプルです。
/**
* @Route("/%eccube_admin_route%/product/category", name="admin_product_category")
* @Route("/%eccube_admin_route%/product/category/{parent_id}", requirements={"parent_id" = "\d+"}, name="admin_product_category_show")
* @Route("/%eccube_admin_route%/product/category/{id}/edit", requirements={"id" = "\d+"}, name="admin_product_category_edit")
* @Template("@admin/Product/category.twig")
*/
public function index(Request $request, $parent_id = null, $id = null, CacheUtil $cacheUtil)
{
ルーティング(ルートアノテーション)
EC-CUBE4ではルートアノテーションを使って、URIを定義します。
URI定義
@Route("/sample")
http://◯◯/sampleのルーティングを作成します
名前付きルート
@Route("/sample",name="sample")
名前付きルートを作成。url(“sample”)で/sampleを生成できます
URIパラメーター
@Route("/sample/{id}",name="sample")
idの部分をパラメーターとして使えます
URIパラメーター正規表現
@Route("/sample/{id}",name="sample",requirements={"id"="\d+"})
idの部分は数字しか認識できないようにします。
スポンサーリンク
スポンサーリンク