2016-05-14 89 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')->??? 
相關問題