-1

Welcome. It is impossible to call its functions from the repository in an Action (Expressive Zend + Doctrine)

___________________

// 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 working as intended, what am I doing wrong? (as far as I remember, in zf2 I had the same problem)

edigu
  • 9,878
  • 5
  • 57
  • 80
Drakulitka
  • 41
  • 6
  • What Errors are you getting? ***Are you sure $this->em is an instance of Entity Manager?*** Although this is not necessary; try adding a back-slash before App like so: **$this->em->getRepository('\App\Entity\Category')->???** – Poiz May 16 '16 at 08:14
  • it worked, thank you – Drakulitka May 16 '16 at 14:46
  • OK... Please, endorse the answer below as the Correct one so that Future visitors with a similar problem might benefit from it? Thanks... Cheers.... – Poiz May 16 '16 at 15:04

2 Answers2

0

What Errors are you getting? Are you sure $this->em is an instance of Entity Manager? Although this is not necessary; try adding a back-slash before App like so:

<?php 
     $this->em->getRepository('\App\Entity\Category')->??? 
Poiz
  • 7,611
  • 2
  • 15
  • 17
0

To get a repository you can use the fully qualified class name:

<?php 

$categoryRepository = $this->em->getRepository(App\Entity\Category::class);
xtreamwayz
  • 1,285
  • 8
  • 10