Sonata找不到自定义块服务

时间:2016-07-08 05:55:06

标签: symfony sonata-admin

我有一种奇怪的情况,现在已经停止了第二天的进展,而我几乎要因为拉扯我的头发而秃顶。我在奏鸣曲管理仪表板上有一个自定义块,当我尝试加载页面时找不到它。

我已经完成了几次配置,也许我错过了一些额外的眼睛可以发现的东西,这就是我在这里发布这个问题的原因。

我已经构建了我的块,如下所示并将其保存在src \ AppBundle \ Block \ NumbersBlockService.php

namespace   AppBundle\Block;
use Symfony\Component\HttpFoundation\Response;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use DoctrineExtensions\Query\Mysql;

class NumbersBlockService extends BaseBlockService
{
    ......
}

然后在service.yml文件中定义我的服务,如下所示:

sonata.block.service.topnumbers:
        class: AppBundle\Block\NumbersBlockService
        arguments:
            -   sonata.block.service.topnumbers
            -   "@templating"
            -   "@doctrine.orm.entity_manager"
            -   "@security.token_storage"
        tags:
            - { name: sonata.block }

我的config.yml文件包含这样的块

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.user.block.menu:    # used to display the menu in profile pages
        sonata.user.block.account: # used to display menu option (login option)
        sonata.block.service.text: # used to if you plan to use Sonata user routes
        sonata.block.service.topnumbers:

最后,我将块放在顶部,并在下面的行

sonata_admin:
    dashboard:
        blocks:
            - { position: top, type: sonata.block.service.topnumbers, class: col-md-12}

我已经在这里检查了有关创建自定义块的教程https://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html,所有内容似乎都已检出,但我仍然会收到以下错误:

An exception has been thrown during the rendering of a template ("The block type "sonata.block.service.topnumbers" does not exist") in SonataAdminBundle:Core:dashboard.html.twig at line 60.

有人请帮助我摆脱痛苦。提前致谢

0 个答案:

没有答案