我正在尝试使用create bundle symfony cmf。到目前为止一切正常,因为我能够编辑块但我无法保存我的内容。我收到以下错误:
Error occurred while saving
[{"message":"Not found: cms\/test","class":"RuntimeException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/var\/www\/JudoSharp\/vendor\/midgard\/createphp\/src\/Midgard\/CreatePHP\/Mapper\/DoctrinePhpcrOdmMapper.php","line":86,"args":[]},{"namespace":"Midgard\\CreatePHP\\Mapper","short_class":"DoctrinePhpcrOdmMapper","class":"Midgard\\CreatePHP\\Mapper\\DoctrinePhpcrOdmMapper","type":"->","function":"getBySubject","file":"\/var\/www\/JudoSharp\/vendor\/symfony-cmf\/create-bundle\/Symfony\/Cmf\/Bundle\/CreateBundle\/Controller\/RestController.php","line":89,"args":[["string","cms\/test"]]},{"namespace":"Symfony\\Cmf\\Bundle\\CreateBundle\\Controller","short_class":"RestController","class":"Symfony\\Cmf\\Bundle\\CreateBundle\\Controller\\RestController","type":"->","function":"getModelBySubject","file":"\/var\/www\/JudoSharp\/vendor\/symfony-cmf\/create-bundle\/Symfony\/Cmf\/Bundle\/CreateBundle\/Controller\/RestController.php","line":108,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","cms\/test"]]},{"namespace":"Symfony\\Cmf\\Bundle\\CreateBundle\\Controller","short_class":"RestController","class":"Symfony\\Cmf\\Bundle\\CreateBundle\\Controller\\RestController","type":"->","function":"putDocumentAction","file":null,"line":null,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","cms\/test"]]},{"namespace":"","short_class":"","class":"","type":"","function":"call_user_func_array","file":"\/var\/www\/JudoSharp\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php","line":117,"args":[["array",[["object","Symfony\\Cmf\\Bundle\\CreateBundle\\Controller\\RestController"],["string","putDocumentAction"]]],["array",[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","cms\/test"]]]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"HttpKernel","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","function":"handleRaw","file":"\/var\/www\/JudoSharp\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/HttpKernel.php","line":61,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"HttpKernel","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","function":"handle","file":"\/var\/www\/JudoSharp\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/DependencyInjection\/ContainerAwareHttpKernel.php","line":62,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\\Component\\HttpKernel\\DependencyInjection","short_class":"ContainerAwareHttpKernel","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->","function":"handle","file":"\/var\/www\/JudoSharp\/vendor\/symfony\/symfony\/src\/Symfony\/Component\/HttpKernel\/Kernel.php","line":187,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"Kernel","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->","function":"handle","file":"\/var\/www\/JudoSharp\/web\/app_dev.php","line":28,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"]]}]}]
我正在使用的前端代码如下:
<div about="cms/test" typeof="schema:WebPage" xmlns:schema="http://schema.org/">
<h1 property="schema:headline">Hey bra</h1>
<div property="schema:text">
<h2>Welcome to the Symfony CMF Demo</h2>
<p>If you see this page, it means that the...</p>
</div>
<p>Brotha!</p>
<p property="schema:sdlkfj">hey</p>
</div>
我不确定“约”属性是什么。 “about = cms / test”只是我放入的一些任意值。我猜它代表了一些phpcr-odm节点,但我甚至不知道在哪里设置该节点,甚至不知道这些文件是如何工作的。我为我的项目创建了我的phpcr-odm数据库并且phpcr-odm正在运行,但我不确定所有这些东西是如何工作的。我是symfony cmf的新手。请告诉我如何使用create bundle保存内容,因为文档很糟糕。我还阅读了有意义的phpcr-odm学说文档,但我不确定如何将它与这个问题联系起来。
感谢。
答案 0 :(得分:1)
你猜对了,是phpcr-odm文件的ID。每个文档在PHPCR中都有自己的路径来识别它。您需要指定“about”中存在的文档的ID。最简单的方法是映射id并执行about =“{{cmfMainContent.id}}”
但真正想做的是阅读rdf映射:http://symfony.com/doc/master/cmf/bundles/create/introduction.html#metadata一旦你定义了它,你可以使用twig helpers来渲染这些属性:http://symfony.com/doc/master/cmf/bundles/create/introduction.html#rendering-content
如果您还有其他问题,请在https://github.com/symfony-cmf/CreateBundle/
上打开github问题