Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Labels:None
Description
if i did not previously load a document of the class of the child, phpcr-odm can not know the alias to load it. it throws an exception.
for example, use $this->documentManager->find('My\Class', '/path/to/document'); where My\Class has an @child annotation for a child that is a File. it has the file alias, but phpcr-odm knows nothing of that alias if i did not previously try to find something with 'Doctrine\...\File' that made it load the meta data.
the workaround is to get the repositories to make phpcr-odm know the alias, but this is no solution.
$this->documentManager->getRepository('Doctrine\ODM\PHPCR\Document\Resource');
$this->documentManager->getRepository('Doctrine\ODM\PHPCR\Document\File');
we could add something to specify the document class in the child annotation, but this sounds stupid.
and getting a document without knowing its document class beforehand would be a nice feature in general. however, the info is currently scattered in annotations over the project. any idea how we could make phpcr-odm know all alias to document class mappings?
to implement extracting the mapping, assetic:dump might give some inspiration. in dev mode, we should extract automatically (maybe with some cache lifetime, depending on how expensive that is - its less obvious than what assetic can do)
it would be something like getAllMetadata in our case, then cache it.