そのため、SonataAdmin の表示ビューを拡張して、ドキュメントのバージョン (phpcr チェックポイントまたはチェックイン) のリストを取得しようとしています。
保存されたバージョンのリストが正しく表示されたので、そのバージョンのコンテンツを表示するリンクにする必要がありますが、カスタム ルートを追加しようとすると次のエラーが発生します。
An exception has been thrown during the rendering of a template
("Parameter "id" for route "admin_cmsbundle_product_show_version" must
match "[^/]++" ("mstr/product/product-253562" given) to generate a
corresponding URL.") in CmsBundle:product:show.html.twig at line 18.
これは私の管理クラスの configureRoutes です:
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('show_version', $this->getRouterIdParameter() . '/show/{version}');
}
これは私のオーバーライドされたテンプレートです:
{% block show %}
<ul>
{% for version in versions %}
<li><a href="{{ admin.generateObjectUrl('show_version', object, {'version': version.name}) }}">Version: {{ version.name }} </a></li>
{% endfor %}
</ul>
{{ parent() }}
{% エンドブロック %}
これは私の編集した show アクションです (バージョン リストを含めるため):
public function showAction($id = null)
{
...
return $this->render($this->admin->getTemplate('show'), array(
'action' => 'show',
'object' => $object,
'elements' => $this->admin->getShow(),
'versions' => $this->getVersionHistory($object)
));
}
そして、これはコントローラーでの私の showVersion アクションです:
public function showVersionAction($id = null, $version = "1.0")
{
...
return $this->render($this->admin->getTemplate('show'), array(
'action' => 'show',
'object' => $this->getVersion($object, $version),
'elements' => $this->admin->getShow(),
'versions' => $this->getVersionHistory($object)
));
}
generateUrl で同じエラーが発生することに注意してください。
<a href="{{ admin.generateUrl('show_version', {'id': object.id, 'version': version.name}) }}">Version: {{ version.name }} </a>
私は何を間違っていますか?
これを修正するための助けがあれば大歓迎です:)