2016-05-14 81 views
-1

欢迎。这是不可能的呼叫从仓库的功能于一身的动作(Zend的表现主义+)在存储库中使用它的函数(Doctrine + Zend表达式)

___________________ 

// App\Entity\Category 
namespace App\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* Category 
* 
* @ORM\Table(name="category", indexes={@ORM\Index(name="id", columns={"id"})}) 
* @ORM\Entity(repositoryClass="App\Repository\CategoryRepository") 
*/ 
class Category 
{//} 
___________________ 

// App\Repository\CategoryRepository 
namespace App\Repository; 

use Doctrine\ORM\EntityRepository; 

class CategoryRepository extends EntityRepository 
{ 
    public function finderMethod($arguments){ 
     // Какие-либо действия 
     return $arguments; 
    } 
} 
___________________ 

// App\Action\PageAction 
$category = $this->em->getRepository('App\Entity\Category')-> ??? 

的findAll(),findBy工作按预期,我究竟做错了什么? (据我记得,在zf2我有同样的问题

+0

你得到什么错误? ***您确定$ this-> em是实体管理器的实例吗?***虽然这不是必需的,尝试在应用程序之前添加反斜杠,例如:** $ this-> em-> getRepository('\ App \ Entity \ Category') - > ** – Poiz

+0

它的工作原理,谢谢 – Drakulitka

+0

确定...请,请将下面的答案认可为正确答案,以便具有类似问题的未来访问者可以从中受益?谢谢...干杯.... – Poiz

回答

0

为了得到一个版本库,你可以使用完全合格的类名:

<?php 

$categoryRepository = $this->em->getRepository(App\Entity\Category::class); 
0

你有什么错误?你确定$ this-> em是一个实体管理器的实例吗?虽然这不是必要的,尝试应用程序前加入一个反斜杠,象这样:

<?php 
    $this->em->getRepository('\App\Entity\Category')->??? 
相关问题