-
Notifications
You must be signed in to change notification settings - Fork 45
[WIP] Persistence #55
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
Conversation
@dbu thinks that we should not support the *Base model for this bundle, and I tend to agree. Another question is if we want to support other persistence layers here? I..e do I need to create |
i am very much +1 for allowing other persistence layers. this is |
realpath(__DIR__ . '/Resources/config/doctrine-model') => 'Symfony\Cmf\Bundle\SimpleCmsBundle\Model', | ||
realpath(__DIR__ . '/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr', | ||
), | ||
array('cmf_simple_cms.manager_name') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make this cmf_simple_cms.persistence.phpcr.manager_name to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This is turning into a bit of an epic refactor - there sure is alot of DI code. As we are removing Multilang and bundling that functionality by default, is there anything else we can do to make the SimpleCMS bundle more simple, especially in terms of the custom Routing setup? // cc @lsmith77 |
i propose to finalize what is in this PR and do further things in a new PR after this one is merged. i think the main thing with the routes is about multilang, as per RoutingBundle the locale is part of the repository path, but for simplecms a special provider is used to extract the locale in the lookup (as we only have one route that is not translated). i guess we should keep that functionality, though maybe it could be simplified. right now we clone the dynamic router service definition and add all kind of things. not sure if there could be something simpler or more generic. we should not just replace/reconfigure the normal dynamic router with this one, or the simplecms bundle could not be combined with things using routing bundle directly... |
agreed |
@@ -12,7 +12,7 @@ | |||
|
|||
use Symfony\Cmf\Component\Routing\RouteObjectInterface; | |||
|
|||
abstract class LoadCmsData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface | |||
abstract class AbstractLoadPageData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed like a more appropriate name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
ok, this now seems to work with Multilang. But it doesn't work with non-multilang. e.g. the test fixtures create "/homepage", but this will only work with "/en/homepage". The bundle doesn't work if we ommit I think we need someway to not add the static prefix /{locale} if locales are not set -- or even better if we can determine if the document has any translations or not. ?? |
To be able to determine if the document has any translations we would need access to the
|
<parameter key="cmf_simple_cms.generator_class">Symfony\Cmf\Bundle\RoutingBundle\Routing\ContentAwareGenerator</parameter> | ||
<parameter key="cmf_simple_cms.phpcrodm_route_idprefix_listener_class">Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\IdPrefixListener</parameter> | ||
<parameter key="cmf_simple_cms.enhancer_route_content_class">Symfony\Cmf\Component\Routing\Enhancer\RouteContentEnhancer</parameter> | ||
<parameter key="cmf_simple_cms.enhancer_explicit_template_class">Symfony\Cmf\Component\Routing\Enhancer\FieldPresenceEnhancer</parameter> | ||
<parameter key="cmf_simple_cms.enhancer_controllers_by_alias_class">Symfony\Cmf\Component\Routing\Enhancer\FieldMapEnhancer</parameter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu these enhancer class parameters do not seem to be used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have our own router, we also need our own enhancers i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure about the implications of what we currently do (using the RoutingBundle enhancers). But in anycase, these parameters are not used anywhere.
Are you suggesting that we create these enhancer services?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't configure enhancers in the bundle config and everything works, lets drop them and see what happens :-) if we did not need them until now, lets drop them. not sure how the main content goes into the request without any enhancer though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enhancers seem to be implemented in the DI Extension with DefinitionDecorator
classes, which are a bit foreign to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right. but guess we need them and can't drop them then. maybe add a
to those parameters then?i think the decorator thing is to avoid instantiating the simple router
if its not used ever. we can't just tag the enhancers as the tag adds
them to the default dynamic router only. not sure if that could be
expressed in xml as well, if its static stuff.
ok, this is potentially done as far as I'm concerned, so good to review. For the multilang stuff I have simply exposed the |
uhm .. the |
@@ -12,10 +12,9 @@ | |||
|
|||
use Symfony\Cmf\Component\Routing\RouteObjectInterface; | |||
|
|||
abstract class LoadCmsData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface | |||
abstract class AbstractLoadPageData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't simply remove this class. Its a bit of a convenience hack, there are probably other libraries that do this sort of thing much better, and it isn't /that/ much harder to do this ad-hoc in the concrete class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it makes it very easy to get started. if we remove it we have to add it to the SE for example https://github.com/symfony-cmf/symfony-cmf-standard/blob/master/src/Acme/MainBundle/DataFixtures/PHPCR/LoadSimpleCmsData.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however we could consider basing this on https://github.com/nelmio/alice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like a really cool library, +1 for adopting it in the SE / Sandbox and dropping this, if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine for me
@lsmith77 you mean or you could keep configuring the locales into this bundle if we need them. |
the corebundle un-translate listener sets the locale to false if it removes translations. you could check getLocale() === false |
|
||
$prefix = $this->getPrefix(); | ||
$path = substr(parent::getId(), strlen($prefix)); | ||
$path = $prefix.'/{_locale}'.$path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not depend on the addLocalePattern flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already returned by now if that flag is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, was not reading carefully
Regarding the "automatic" prefixing of the locale in the URL depending on if it has bound translations or not - its not clear to me on how to proceed:
What happens in this PR currently is this:
So the user chooses what happens, much like they would have choosen if they were going to use And I wonder if there isn't some scope here for a new Translatable interface, e.g. EDIT: Found one: http://en.wiktionary.org/wiki/activable#English :) |
* **2013-08-10**: Removed "tags" property, see: https://github.com/symfony-cmf/SimpleCmsBundle/issues/53 | ||
* **2013-08-08**: | ||
* Seperate Multilang document now incorporated in single document | ||
* `multilang.locales` config removed (use cmf_core.multilang.locales) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? I prefer each Bundle to have its own setting and rely on CoreBundle to ease handling for duplicate settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does SimpleCmsBundle itself still do anything with locales? if not, there is no need to configure them. but maybe the routes with the automatic locale prefixing need it to put a requirement on _locale?
So I guess what we need now is:
|
- Multilang works, non-multilang doesnt
- Collapsed PageBase into Page
lets keep the old way and do alice later, so that we can merge this PR soon |
|
||
/** | ||
* Extra values an application can store along with a page | ||
* | ||
* @PHPCRODM\String(assoc="") | ||
*/ | ||
protected $extras; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should init this with = array()
Migration instructions in CHANGELOG.md, they depend on https://github.com/doctrine/DoctrinePHPCRBundle/pull/84/files |
ok, I have added a small test for the migrator and re-added DataFixtures base-class. This is potentially good to merge I think. |
looks like the tests need fixes for the non nullable fields |
ah .. is this fixed by changes in RoutingBundle? |
Implementing Model model ... FOR REVIEW