2016-02-24 87 views
0

我的问题是,我试图执行一个命令,但是给我的下一个错误:尝试加载类错误的Symfony 2

Attempted to load class "XMLReport" from namespace "BusinessName\Core\LibraryDatabaseBundle\Repository". Did you forget a "use" statement for "BusinessName\Core\LibraryDatabaseBundle\Entity\XMLReport"?

repository类使用命名空间:

namespace Mundoreader\Core\LibraryDatabaseBundle\Repository; 

use Doctrine\ORM\Query\QueryException; 
use Doctrine\ORM\Query\ResultSetMapping; 
use Doctrine\ORM\QueryBuilder; 
use Mundoreader\Core\LibraryDatabaseBundle\Entity\Library; 

/** 
* Class XMLReportRepository 
* 
*/ 
class XMLReportRepository extends AbstractRepository 
{/*code 
} 

命令类:

class GenerateXMLCommand extends AbstractCommand 
{ 

    protected function configure() 
    { 
     $this 
      ->setName('library:reports:generateXML') 
      ->setDescription('Generate XML'); 
    }  
protected function execute(InputInterface $input, OutputInterface $output) 
     { 
      $statusToDo   = $this->xmlReportRepo->countAllStatusToDo(); 

      if($statusToDo) 
      { 

       //XML BBDD 
       $emXML   = new XMLReport(); 
       $libraryXML  = $emXML->getLibrary(); 
       $isbnXML  = $emXML->getISBN(); 
       $toDateXML  = $emXML->getReportDateEnd(); 
       $fromDateXML = $emXML->getReportDateStart(); 
       $arrayXMLInfo = array(
        ['fromDate'] => $fromDateXML, 
        ['toDate']  => $toDateXML, 
        ['library']  => $libraryXML, 
        ['isbn']  => $isbnXML 
       ); 
    /*More Code 
    } 

我不知道哪里是错误的,因为我在调用库:

$statusToDo   = $this->xmlReportRepo->countAllStatusToDo(); 

在扩展类我的路线:

abstract class AbstractCommand extends ContainerAwareCommand 
{ 
public function setContainer(ContainerInterface $container = null) 
    { 
     $this->xmlReportRepo = $this->doctrine->getRepository('MrLibraryDatabaseBundle:XMLReport'); 
    } 
} 

PD:对不起,我的英语不好。

+0

您在GenerateXMLCommand的顶部添加了“使用BusinessName \ Core \ LibraryDatabaseBundle \ Entity \ XMLReport”吗? – Twifty

+0

是的,我做过。所以我不知道问题在哪里。 – Sermanes

+0

看起来您尝试在XMLReport XMLReportRepository中使用XMLReport类。您可以显示XMLReportRepository类代码并将Block用于GenerateXMLCommand类 –

回答

1

请检查您的映射定义中的存储库类。应该是这样的:

// src/AppBundle/Entity/Product.php 
namespace AppBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Entity(repositoryClass="AppBundle\Entity\ProductRepository") 
*/ 
class Product 
{ 
    //... 
} 
+0

是的,我拥有它:S – Sermanes