尝试创建Admin Bundle类时出现Symfony错误

时间:2012-10-01 17:13:22

标签: symfony sonata-admin

我正在尝试使用SonataAdminBundle来启动和运行一些后端管理功能,但是我的第一个配置类遇到了障碍。

我已将以下内容添加到app / config / config.yml

services:
    sonata.admin.sport:
        class: Clarity\CoachTimeBundle\Admin\SportAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: General, label: Sports}
        arguments: [null, Clarity\CoachTimeBundle\Entity\Sport, null]

并在路径src / Clarity / CoachTimeBundle / Admin / SportAdmin.php中定义以下类

<?
namespace Clarity\CoachTimeBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;

class SportAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name');
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('name');
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('name');
    }

    public function validate(ErrorElement $errorElement, $object)
    {
        $errorElement
            ->with('name')
                ->assertMaxLength(array('limit' => 255))
            ->end();
    }
}

当我尝试清除缓存并运行应用程序时,我收到以下错误:   自动加载器期望在文件“src // Clarity / CoachTimeBundle / Admin / SportAdmin.php”中定义类“Clarity \ CoachTimeBundle \ Admin \ SportAdmin”。找到了该文件,但该类不在其中,类名或命名空间可能有拼写错误。

谢谢, 安德鲁

0 个答案:

没有答案