sulu 扩展 PageDocument

sulu extend PageDocument

我正在尝试扩展 PageDocument class。我在 app/config/config.yml

中添加了以下设置
sulu_document_manager:
    mapping:
        page:
            class: Client\Bundle\WebsiteBundle\Document\PageDocument
            phpcr_type: sulu:page

class Client\Bundle\WebsiteBundle\Document\PageDocument 只是扩展了 class Sulu\Bundle\ContentBundle\Document\PageDocument

namespace Client\Bundle\WebsiteBundle\Document;

use Sulu\Bundle\ContentBundle\Document\PageDocument as BasePageDocument;

class PageDocument extends BasePageDocument
{
}

在前端打开页面可以,但在后端编辑页面会在预览区域抛出以下错误消息:

Metadata with class "Sulu\Bundle\ContentBundle\Document\PageDocument" 
not found, known classes: "Client\Bundle\WebsiteBundle\Document
\PageDocument", "Sulu\Bundle\ContentBundle\Document\HomeDocument", 
"Sulu\Bundle\ContentBundle\Document\RouteDocument", "Sulu\Bundle
\SnippetBundle\Document\SnippetDocument", "Client\Bundle\WebsiteBundle
\Document\RegionDocument" 

500 Internal Server Error - MetadataNotFoundException 

堆栈跟踪

1. in vendor/sulu/document-manager/lib/Metadata/BaseMetadataFactory.php at line 132  -

//echo '<pre>$class: '; var_dump($class); echo '</pre>';
    if (!isset($this->classMap[$class])) {
        throw new MetadataNotFoundException(sprintf(
            'Metadata with class "%s" not found, known classes: "%s"',
                $class, implode('", "', array_keys($this->classMap))
        ));

2. at BaseMetadataFactory ->getMetadataForClass ('Sulu\Bundle\ContentBundle\Document\PageDocument')
in vendor/sulu/document-manager/lib/Metadata/MetadataFactory.php at line 78  +
3. at MetadataFactory ->getMetadataForClass ('Sulu\Bundle\ContentBundle\Document\PageDocument')
in vendor/sulu/sulu/src/Sulu/Bundle/DocumentManagerBundle/Bridge/DocumentInspector.php at line 125  +
4. at DocumentInspector ->getMetadata (object(PageDocument))
in vendor/sulu/sulu/src/Sulu/Bundle/DocumentManagerBundle/Bridge/DocumentInspector.php at line 111  +
5. at DocumentInspector ->getStructureMetadata (object(PageDocument))
in vendor/sulu/sulu/src/Sulu/Bundle/DocumentManagerBundle/Bridge/DocumentInspector.php at line 262  +
6. at DocumentInspector ->getLocalizedUrlsForPage (object(PageDocument))
in vendor/sulu/sulu/src/Sulu/Component/Content/Compat/Structure/PageBridge.php at line 35  +
7. at PageBridge ->getUrls ()
in vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Resolver/StructureResolver.php at line 65  +
8. at StructureResolver ->resolve (object(PageBridge))
in vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Resolver/ParameterResolver.php at line 57  +
9. at ParameterResolver ->resolve (array(), object(AdminRequestAnalyzer), object(PageBridge), true)
in vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Controller/WebsiteController.php at line 84  +
10. at WebsiteController ->getAttributes (array(), object(PageBridge), true)
in vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Controller/WebsiteController.php at line 46  +
11. at WebsiteController ->renderStructure (object(PageBridge), array(), true, false)
in vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/Controller/DefaultController.php at line 41  +
12. at DefaultController ->indexAction (object(PageBridge), true, false)
in vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Preview/PreviewRenderer.php at line 92  +
13. at PreviewRenderer ->render (object(PageBridge), false)
in vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Preview/Preview.php at line 223  +
14. at Preview ->renderStructure (object(PageBridge), false, null)
in vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Preview/Preview.php at line 212  +
15. at Preview ->render ('1', '8a7d4c4a-60b4-4ced-9b3b-007e238810ff', 'sulu_io', 'en')
in vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Controller/PreviewController.php at line 57  +
16. at PreviewController ->renderAction (object(Request), '8a7d4c4a-60b4-4ced-9b3b-007e238810ff')
17. at call_user_func_array (array(object(PreviewController), 'renderAction'), array(object(Request), '8a7d4c4a-60b4-4ced-9b3b-007e238810ff'))
in app/bootstrap.php.cache at line 3054  +
18. at HttpKernel ->handleRaw (object(Request), '1')
in app/bootstrap.php.cache at line 3016  +
19. at HttpKernel ->handle (object(Request), '1', true)
in app/bootstrap.php.cache at line 3165  +
20. at ContainerAwareHttpKernel ->handle (object(Request), '1', true)
in app/bootstrap.php.cache at line 2406  +
21. at Kernel ->handle (object(Request))
in web/admin.php at line 44  +

我不敢告诉你这个行为是一个错误...我可以稍微追踪一下并创建一个 issue on GitHub,你可以在那里追踪进一步的进展。

但是,此错误仅影响预览,不会影响系统的其余部分。