$contentDocument控制器操作参数,带Symfony CMF动态路由器

$contentDocument控制器操作参数,带Symfony CMF动态路由器,symfony,routing,symfony-cmf,symfony-4.3,doctrine-phpcr,Symfony,Routing,Symfony Cmf,Symfony 4.3,Doctrine Phpcr,在将Symfony CMF和自动路由绑定集成到我的应用程序中之后,我遵循了文档。我的问题与类似,但即使正确命名参数,我也无法解决问题 我可以创建一个页面文档,并自动为其创建一个自动路由,但当尝试使用控制器显示该页面时,我无法按照文档的建议将$contentDocument参数放入控制器操作中。添加参数时,出现以下错误: 无法解析“App\ContentBundle\Controller\PageController::pageaction()”的参数$contentDocument,可能是您忘记

在将Symfony CMF和自动路由绑定集成到我的应用程序中之后,我遵循了文档。我的问题与类似,但即使正确命名参数,我也无法解决问题

我可以创建一个
页面
文档,并自动为其创建一个
自动路由
,但当尝试使用控制器显示该页面时,我无法按照文档的建议将
$contentDocument
参数放入控制器操作中。添加参数时,出现以下错误:

无法解析“App\ContentBundle\Controller\PageController::pageaction()”的参数$contentDocument,可能是您忘记将控制器注册为服务,或者没有用“Controller.service\u参数”标记它

即使控制器按建议标记,错误仍然存在

如果在没有
$contentDocument
参数的情况下呈现页面模板,我可以看到它,但无法获取
页面
属性

这是我的
页面
文档:

/**
*类页
*@package-App\ContentBundle\Document
*
*@Document(translator=“attribute”,referenceable=true)
*/
类页面实现
可翻译接口,
RouterFerrersReader接口
{
/**
*@var字符串
*@Id()
*/
受保护的$id;
/**
*@var字符串
*@Uuid()
*/
受保护的$uuid;
/**
*@var对象
*@ParentDocument()
*/
受保护的$父母;
/**
*@推荐人(
*refereringdocument=“Symfony\Cmf\Bundle\RoutingBundle\document\Phpcr\Route”,
*referencedBy=“内容”
* )
*/
受保护的路线;
/**
*@var字符串|布尔值
*@Locale()
*/
私人$locale;
/**
*@var字符串|空
*@Nodename()
*/
私人$slug;
/**
*@var字符串|空
*@Field(type=“string”,nullable=false)
*/
私人产权;
/**
*@var\Sonata\BlockBundle\Model\BlockInterface[]
*@Children()
*/
私人大厦;;
公共函数构造()
{
$this->blocks=[];
}
/**
*@返回字符串
*/
公共函数getId()
:字符串
{
返回$this->id;
}
/**
*@返回对象
*/
公共函数getParentDocument()
:对象
{
返回$this->parent;
}
/**
*@param对象$parent
*/
公共函数setParentDocument($parent)
:无效
{
$this->parent=$parent;
}
/**
*@返回混合
*/
公共函数getRoutes()
{
返回$this->routes;
}
/**
*@return bool | string
*/
公共函数getLocale()
{
返回$this->locale;
}
/**
*@param bool | string$locale
*/
公共函数setLocale($locale)
:无效
{
$this->locale=$locale;
}
/**
*@返回字符串|空
*/
公共函数getSlug()
:?字符串
{
返回$this->slug;
}
/**
*@param string | null$slug
*/
公共函数设置片(?字符串$slug)
:无效
{
$this->slug=$slug;
}
/**
*@返回字符串|空
*/
公共函数getTitle()
:?字符串
{
返回$this->title;
}
/**
*@param string | null$title
*/
公共函数setTitle(?字符串$title)
:无效
{
$this->title=$title;
}
/**
*@return\Sonata\BlockBundle\Model\BlockInterface[]
*/
公共函数getBlocks()
:数组
{
返回$this->blocks;
}
/**
*@param\Sonata\BlockBundle\Model\BlockInterface[]$blocks
*/
公共函数设置块(数组$块)
:无效
{
$this->blocks=$blocks;
}
}
Symfony CMF配置:

cmf_routing:
    chain:
        routers_by_id:
            router.default: 200
            cmf_routing.dynamic_router: 100
    dynamic:
        persistence:
            phpcr:
                enabled: true
                manager_name: default
        controllers_by_class:
            App\ContentBundle\Document\Page: App\ContentBundle\Controller\PageController::pageAction
cmf\u routing\u auto.yml
在我的包中:

App\ContentBundle\Document\Page:
    definitions:
        main:
            uri_schema: /{slug}
    token_providers:
        slug: [content_method, {method: getSlug}]
以及控制器动作:

/**
*@Template()
*@param$contentDocument
*
*@return数组
*/
公共函数页面操作($contentDocument)
{
返回[
“页面”=>$contentDocument,
];
}