Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with 2 ODM managers and default mapping #280

Closed
rivaros opened this issue Aug 8, 2017 · 2 comments
Closed

Issue with 2 ODM managers and default mapping #280

rivaros opened this issue Aug 8, 2017 · 2 comments

Comments

@rivaros
Copy link
Contributor

rivaros commented Aug 8, 2017

Have no other way but to ask. I am trying to use 2 PHPCR ODM document managers for my project.

# cmf configuration
doctrine_phpcr:
    # configure the PHPCR session
    ......
    # enable the ODM layer
    odm:
        auto_generate_proxy_classes: %kernel.debug%
        document_managers:
            default:
                session: default
                mappings:
                    MMPGlobalServicesBundle: ~
            secondary:
                session: secondary
                mappings:
                    MMPGlobalServicesBundle: ~
        .....

The problem is that though they have SAME configuration, the complete mapping:info is available only for first one (default). See below:

php app/console doctrine:phpcr:mapping:info
Found 43 documents mapped in document manager:
[OK]   MMP\GlobalServicesBundle\Document\DemoClassContent
[OK]   MMP\GlobalServicesBundle\Document\DemoTemplateContent
[OK]   MMP\GlobalServicesBundle\Document\EmailContent
[OK]   MMP\GlobalServicesBundle\Document\Image
[OK]   MMP\GlobalServicesBundle\Document\SecuredMenuNode
[OK]   MMP\GlobalServicesBundle\Document\SliderImage
[OK]   Doctrine\ODM\PHPCR\Document\AbstractFile
[OK]   Doctrine\ODM\PHPCR\Document\File
[OK]   Doctrine\ODM\PHPCR\Document\Folder
[OK]   Doctrine\ODM\PHPCR\Document\Generic
[OK]   Doctrine\ODM\PHPCR\Document\Resource
[OK]   Symfony\Component\Routing\Route
[OK]   Symfony\Cmf\Bundle\RoutingBundle\Model\RedirectRoute
[OK]   Symfony\Cmf\Bundle\RoutingBundle\Model\Route
[OK]   Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute
[OK]   Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route
[OK]   Symfony\Cmf\Bundle\MenuBundle\Model\Menu
[OK]   Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode
[OK]   Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeBase
[OK]   Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu
[OK]   Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
[OK]   Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNodeBase
[OK]   Symfony\Cmf\Bundle\ContentBundle\Model\StaticContent
[OK]   Symfony\Cmf\Bundle\ContentBundle\Model\StaticContentBase
[OK]   Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent
[OK]   Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContentBase
[OK]   Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page
[OK]   Symfony\Cmf\Bundle\BlockBundle\Model\AbstractBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ActionBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ImagineBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\MenuBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\RssBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SlideshowBlock
[OK]   Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\StringBlock
[OK]   Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\AbstractMedia
[OK]   Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Directory
[OK]   Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\File
[OK]   Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image
[OK]   Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Media

The second one (secondary) has a problem

php app/console doctrine:phpcr:mapping:info --session=secondary
Found 11 documents mapped in document manager:
[OK]   MMP\GlobalServicesBundle\Document\DemoClassContent
[OK]   MMP\GlobalServicesBundle\Document\DemoTemplateContent
[OK]   MMP\GlobalServicesBundle\Document\EmailContent
[OK]   MMP\GlobalServicesBundle\Document\Image
[OK]   MMP\GlobalServicesBundle\Document\SliderImage
[OK]   Doctrine\ODM\PHPCR\Document\AbstractFile
[OK]   Doctrine\ODM\PHPCR\Document\File
[OK]   Doctrine\ODM\PHPCR\Document\Folder
[OK]   Doctrine\ODM\PHPCR\Document\Generic
[OK]   Doctrine\ODM\PHPCR\Document\Resource

As you may see all chain of phpcr namespaces (related to PhpcrMappingPass) are not loaded. So I am unable to use the secondary document manager and get consequent errors like

The class 'Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page' was not found in the chain configured namespaces MMP\GlobalServicesBundle\Document, Doctrine\ODM\PHPCR\Document
@dbu
Copy link
Member

dbu commented Aug 21, 2017

intuitively i feel like you should have to specify all the other locations in your second manager, but thats indeed not very user friendly. can you check how is this solved in doctrine orm? do they have some logic to include parent classes in the mapping?

the thing that is particular about the cmf is that many of our bundles provide default models and we register those with doctrine in the bundle configuration with the help of a compilar pass: https://github.com/symfony-cmf/routing-bundle/blob/47be1b0eb96e5ab7db5fa921a0342e38f3915795/src/CmfRoutingBundle.php#L65-L75

i think we could specify more than one manager name - maybe the right fix would be to allow to configure a list of managers https://github.com/symfony-cmf/routing-bundle/blob/47be1b0eb96e5ab7db5fa921a0342e38f3915795/src/DependencyInjection/Configuration.php#L109

do you want to do pull requests to the cmf bundles to add that feature? it needs to be done in a BC way, that is manager_name must still be accepted.

@dbu dbu added this to the 2.0 milestone Jan 24, 2018
@dbu
Copy link
Member

dbu commented Feb 24, 2018

it looks like the orm is doing the same, you don't usually have an entity registered in more than one manager: https://symfony.com/doc/current/doctrine/multiple_entity_managers.html

we certainly should not by default register all documents with all managers. do you want to look further into it or shall we drop the issue?

@dbu dbu removed this from the 2.0 milestone Feb 24, 2018
@dbu dbu closed this as completed May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants