Hi!
I don't relly like the usage of strings when the same value is used all
over the project.
To write 100x 'MyNamespace\Model\MyEntity' is quite bad if you want to
refactor things some times.
>From doctrine manual:
$user = $em->find('MyProject\Domain\User', $id);
>From symfony manual:
$repository = $this->getDoctrine()->getRepository('AcmeStoreBundle:Product'
);
As long as your entity lives under the Entity namespace of your bundle, this
will work.
My best idea is to implement a constant and use this when requesting a
repository.
namespace MyNamespace;
class MyEntity {
const ENTITY_NAME = __CLASS__;
}
and then call
$this->getDoctrine()->getRepository(MyNamespace\MyEntity::ENTITY_NAME);
With this construct I'm able to refactor the classes because the MyNamespace
\MyEntity will be updated or will be invalid.
*Another possiblity would be a trait with "public static function
entityName() { return __CLASS__; }" and use this in every entity, but i
think this is the same solution. :) *
Does anyone have a better idea?
kr sebastian
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.