我的问题是,我正在尝试执行命令,但给我下一个错误:
试图从命名空间加载类"XMLReport" "BusinessName''Core''LibraryDatabaseBundle''Repository"。 你 忘记 的"使用"语句 "BusinessName''Core''LibraryDatabaseBundle''Entity''XMLReport"?
存储库类正在使用命名空间:
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:对不起,我的英语不好。
请检查映射定义中的存储库类。应该有这样的东西:
// src/AppBundle/Entity/Product.php
namespace AppBundle'Entity;
use Doctrine'ORM'Mapping as ORM;
/**
* @ORM'Entity(repositoryClass="AppBundle'Entity'ProductRepository")
*/
class Product
{
//...
}