create-bundle
create-bundle copied to clipboard
add support for orm mapper
once the orm mapper has landed in createphp, we should support it in the bundle as well. we need a persistence-orm.xml file similar to persistence-phpcr.xml and the configuration options in the "persistence" tree.
the orm service will look something like
create_orm_mapper:
class: Midgard...\DoctrineOrmMapper
arguments: ['%cmf_create.map%', '@doctrine']
and CmfCreateExtension will have to be adjusted to wire things together correctly
the createphp code is merged. now we just need to leverage the new functionality in this bundle :-)
/cc @pjedrzejewski
we should implement https://github.com/flack/createphp/issues/58 as well to get the full power out of this.
Based on what I've read I got the impression that using this with Doctrine ORM isn't ready yet. It was actually quite easy to set up.
cmf_create:
object_mapper_service_id: cmf_create.persistence.orm.object_mapper
services:
cmf_create.persistence.orm.object_mapper:
class: Midgard\CreatePHP\Mapper\DoctrineOrmMapper
arguments:
- "%cmf_create.map%"
- "@doctrine"
Works well. Thanks.
yeah, i think the doc was written before that was added to createphp.
i was holding back with adding support to CreateBundle, hoping somebody would find time to implement https://github.com/flack/createphp/issues/58 so that we can get full flexibility in CreateBundle.
there is now a chain mapper being added to createphp.
so we should be able to
- add configuration for orm mapper
- configuration to add any number of mappers to the default mapper which would be the chain mapper
- a container tag to autoregister mappers
- one further step would be to support multiple mappers on the same storage (orm, phpcr-odm) for when you have multiple orm entity managers on multiple database connections.
I think creating the configuration for the ORM mapper and container tag is rather straightforward.
What I'm not too clear on is how to best go about deciding to enable/disable the ORM and/or PHPCR mapper. Would this just be a matter of adding a "orm.enabled" setting under persistence and loading the orm mapper configuration when it is enabled in the CmfCreateExtension class (as phpcr as done)?
For supporting multiple mappers on the same storage, were you thinking that we could auto discover them or require all the managers enabled for to be listed in the configuration?
about enabled: look at the phpcr configuration. the canBeEnabled in the config builder makes enabled: true whenever any of the options below that is set. so setting just the orm entity manager sets enabled to true automatically. you could still manually set enabled to false if you really want to (e.g. parameters.yml or other flexible means).
the automatic mapping of all managers sounds interesting. i wonder if any bundle does that for any purpose yet. but i propose we postpone this topic and first get one orm mapper working the classic way, ok? once we have the chain mapper and one orm mapper, we cover most cases already, with the option to manually define more mappers for other doctrine connections. that would be pretty good already.