5

音楽を管理するために Symfony 2.3.5 でアプリケーションを作成しています。ルートの設定に問題があります。

3 つのルートを作成したい:

  • アーティストを表示:/music/mickael_jackson
  • アーティストの編集 :/music/mickael_jackson/edit
  • アルバムを表示:/music/mickael_jackson/thriller

ご覧のとおり、「アーティストの編集」と「アルバムの表示」のルート間に競合が発生します。「アーティストの編集」は「アルバムの表示ルート」として捕捉され、404 not found が表示されます。

edit正規表現を使用してキーワードを除外しdelete、ルート「アルバムを表示」から除外しようとしています。

ここで見つけました:単語/文字列を除外する正規表現(少し変更して受け入れられた回答)ですが、機能しません。ルート「アルバムを表示」が正規表現と一致しなかったため、エラーが発生しました。

例外 :

An exception has been thrown during the rendering of a template ("Parameter "nameCanonical" for route "corum_music_album_show" must match "/(?!edit|delete)" ("beneath_the_encasing_of_ashes" given) to generate a corresponding URL.") in CorumMusicBundle:Artist:show.html.twig at line 36. 

私のルート:

* @Route(
*         "{artistNameCanonical}/{nameCanonical}",
*         name = "corum_music_album_show",
*         requirements={"nameCanonical" = "^/(?!edit|delete)$"},
*         options = {"expose"=true}
* )

構成の何が問題なのかわかりません。

手伝ってくれてありがとう。

4

3 に答える 3

0

Just move your "Edit artist" route before "Show Album" route. Of course, you won't be able to use "edit" as a name of an album, but I suppose you can live with that.

于 2017-09-19T13:21:14.120 に答える