簡體   English   中英

ReflectionException:類Admin \\ AdminBundle \\ Admin \\ Entity \\ Produit不存在

[英]ReflectionException : Class Admin\AdminBundle\Admin\Entity\Produit does not exist

我使用symfony 3,嘗試管理一個管理端來管理我的電子商務網站的產品和命令,但是我始終遇到相同的錯誤:

ReflectionException-類Admin \\ AdminBundle \\ Admin \\ Entity \\ Product不存在

這是我的服務:

services:
app.admin.produit:
    class: Admin\AdminBundle\Admin\ProduitAdmin
    tags:
        - { name: sonata.admin, manager_type: orm, group: "Content", label: "Produit" }
    arguments:
        - ~
        - Admin\AdminBundle\Admin\Entity\Produit
        - ~
    calls:
        - [ setTranslationDomain, [AdminAdminBundle]]
    public: true


app.admin.commande:
    class: Admin\AdminBundle\Admin\CommandeAdmin
    tags:
        - { name: sonata.admin, manager_type: orm, group: "Content", label: "Commande" }
    arguments:
        - ~
        - Admin\AdminBundle\Admin\Entity\Commande
        - ~
    calls:
        - [ setTranslationDomain, [AdminAdminBundle]]
    public: true

這是我的CommandAdmin:

    <?php
    namespace Admin\AdminBundle\Admin;



    use Sonata\AdminBundle\Admin\AbstractAdmin;
       use Sonata\AdminBundle\Show\ShowMapper;
       use Sonata\AdminBundle\Form\FormMapper;
       use Sonata\AdminBundle\Datagrid\ListMapper;
       use Sonata\AdminBundle\Datagrid\DatagridMapper;

class CommandeAdmin extends AbstractAdmin
{
    // Fields to be shown on create/edit forms
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('idProduit', 'entity', array('class' => 'Admin\AdminBundle\Entity\Produit'))
            ->add('date')
       ;
    }

    // Fields to be shown on filter forms
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
       $datagridMapper
            // ->add('idProduit')
            ->add('date')
       ;
    }

    // Fields to be shown on lists
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('idProduit', 'entity', array('class' => 'Admin\AdminBundle\Entity\Produit'))
            ->add('date')
       ;
    }

    // Fields to be shown on show action
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
           ->add('idProduit')
           ->add('date')
       ;
    }
}

這是我的ProduitAdmin:

<?php
namespace Admin\AdminBundle\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;

class ProduitAdmin extends AbstractAdmin
{
    // Fields to be shown on create/edit forms
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('nom')
            ->add('description')
            ->add('quantite')
            ->add('prix')
            ->add('marque')
            ->add('fournisseur')
       ;
    }

    // Fields to be shown on filter forms
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
       $datagridMapper
            ->add('nom')
            ->add('description')
            ->add('quantite')
            ->add('prix')
            ->add('marque')
            ->add('fournisseur')
       ;
    }

    // Fields to be shown on lists
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('nom')
            ->add('description')
            ->add('quantite')
            ->add('prix')
            ->add('marque')
            ->add('fournisseur')
       ;
    }

    // Fields to be shown on show action
    protected function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
           ->add('nom')
           ->add('description')
           ->add('quantite')
           ->add('prix')
           ->add('marque')
           ->add('fournisseur')
       ;
    }
}

這是堆棧跟蹤:

ReflectionException:
Class Admin\AdminBundle\Admin\Entity\Produit does not exist

  at vendor/sonata-project/admin-bundle/Controller/CRUDController.php:480
  at ReflectionClass->__construct('Admin\\AdminBundle\\Admin\\Entity\\Produit')
     (vendor/sonata-project/admin-bundle/Controller/CRUDController.php:480)
  at Sonata\AdminBundle\Controller\CRUDController->createAction()
  at call_user_func_array(array(object(CRUDController), 'createAction'), array())
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:153)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:169)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:29)

如果有人有想法

該錯誤是可以解釋的: Admin\\AdminBundle\\Admin\\Entity\\Produit類似乎不存在。 看一下您的代碼,我猜它不存在。

我最好的猜測是您的意思是Admin\\AdminBundle\\Entity\\Produit (請注意已刪除的Admin\\命名空間)。 這同樣適用於其下方的Commande類規范。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM