Reputation: 4169
When re-writing the constructor in my entity manager, this doesn't work:
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityRepository;
class UserRepository extends EntityRepository
{
function __construct()
{
parent::__construct();
$this->CI =& get_instance();
}
public function getUserFromKey()
{
// Rest of the function/class ..
Why ? (I get massive erros from Doctrine ORM core)
Upvotes: 1
Views: 3364
Reputation: 12033
Doctrine EntityRepository has some params in constructor, you need to copy it and past to parent constructor
/**
* Initializes a new <tt>EntityRepository</tt>.
*
* @param EntityManager $em The EntityManager to use.
* @param Mapping\ClassMetadata $class The class descriptor.
*/
public function __construct($em, Mapping\ClassMetadata $class)
{
$this->_entityName = $class->name;
$this->_em = $em;
$this->_class = $class;
}
For example
class UserRepository extends EntityRepository
{
function __construct($em, Mapping\ClassMetadata $class)
{
parent::__construct($em, $class);
$this->CI =& get_instance(); // looks strange
}
Upvotes: 5