There is Entity
/**
* @ORM\Entity(repositoryClass="Some\Namspace\CustomRepository")
* @ORM\Table(name="image_type")
*/
class MyEntity{...}
and CustomRepository extends EntityRepository to override some methods like find
or findAll
documentation says:
// $em instanceof EntityManager $user = $em->find('MyProject\Domain\User', $id);
Essentially, EntityManager#find() is just a shortcut for the following:
$user = $em->getRepository('MyProject\Domain\User')->find($id);
link:doctrine-orm.readthedocs.org
but my CustomRepository
works only with $em->getRepository('Entities\MyEntity')->find($id)
using $em->find('Entities\MyEntity',$id);
ignoring my overrided methods in CustomRepository
- so is this a bug?
- or there's a difference between this construcions?
- how can i overide
find
,finAll
,...
methods for my entity without overriding EntityManager?
Edit (1)
using composer:
"require": {
"doctrine/orm": "~2.4"
},
find
code:
public function find($entityName, $id, $lockMode = null, $lockVersion = null)
{
$class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
if ( ! is_array($id)) {
if ($class->isIdentifierComposite) {
throw ORMInvalidArgumentException::invalidCompositeIdentifier();
}
$id = array($class->identifier[0] => $id);
}
........... other ~100 lines
}