Symfony2访问实体中的学说

时间:2015-01-29 18:40:06

标签: php symfony doctrine-orm doctrine

有我的实体:

实体

namespace Catalog\WebBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

class ComCompany
{

    private $entityManager;

    public function setEntityManager(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function getCmpCategory()
    {
         return  $customer = $this
                ->entityManager
                ->getRepository('CatalogWebBundle:ComCategory')
                ->findOneBycmpCat('123123');
    }


}

Services.yml

services:
catalog_web.comcompany:
    class: Catalog\WebBundle\Entity\ComCompany
    calls:
        - [ setEntityManager, [ @doctrine.orm.entity_manager ]]

我收到错误:

InvalidArgumentException:没有扩展程序可以加载“catalog_web.comcompany”的配置(在/home/katalogas/domains/ekatalogas.eu/public_html/src/Catalog/WebBundle/DependencyInjection/../Resources /config/services.yml)。查找命名空间“catalog_web.comcompany”,找不到

我不了解problam在services.yml配置文件中的含义。

1 个答案:

答案 0 :(得分:0)

您的.yml间距错误。它应该是:

services:
   catalog_web.comcompany:
      class: Catalog\WebBundle\Entity\ComCompany
      calls:
          - [ setEntityManager, [ @doctrine.orm.entity_manager ]]