Doctrine PHPCR
  1. Doctrine PHPCR
  2. PHPCR-2

load document with child annotation

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major 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?

        Activity

        Hide
        David Buchmann added a comment - - edited

        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.

        Show
        David Buchmann added a comment - - edited 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.
        Hide
        David Buchmann added a comment - - edited

        according to benjamin, mongo-odm uses an attribute targetDocument that is set to the document class, so the annotation seems not such a bad idea after all.

        not sure how to handle a case when we have children with varying document classes, though. but targetDocument would be a start, and cover many common cases.

        Show
        David Buchmann added a comment - - edited according to benjamin, mongo-odm uses an attribute targetDocument that is set to the document class, so the annotation seems not such a bad idea after all. not sure how to handle a case when we have children with varying document classes, though. but targetDocument would be a start, and cover many common cases.
        Hide
        David Buchmann added a comment -

        after more dicussion with benjamin: in mongo, benjamin does no longer store an alias but directly the document class. we could also do that.

        Show
        David Buchmann added a comment - after more dicussion with benjamin: in mongo, benjamin does no longer store an alias but directly the document class. we could also do that.
        Hide
        Uwe Jäger added a comment -

        As you say this is more an issue with the meta-data handling within the odm. The same issue will apply to references and to parent and children annotations I guess. Storing the class directly and loading the meta-data via the class when needed seems a good solution to me.

        Show
        Uwe Jäger added a comment - As you say this is more an issue with the meta-data handling within the odm. The same issue will apply to references and to parent and children annotations I guess. Storing the class directly and loading the meta-data via the class when needed seems a good solution to me.
        Hide
        David Buchmann added a comment -

        we now store the phpcr:class instead of phpcr:alias. the alias is still supported for legacy.

        https://github.com/doctrine/phpcr-odm/pull/45

        Show
        David Buchmann added a comment - we now store the phpcr:class instead of phpcr:alias. the alias is still supported for legacy. https://github.com/doctrine/phpcr-odm/pull/45

          People

          • Assignee:
            Jordi Boggiano
            Reporter:
            David Buchmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: