Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Allow disabling of content listener. #209

Merged
merged 1 commit into from
Feb 20, 2015

Conversation

benglass
Copy link
Member

@benglass benglass commented Feb 6, 2015

We are working on integrating this into our CMS but would like to use our own content listener.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes

TO DO

  • Add enable_content_listener boolean node
  • Update XML schema
  • Add tests
  • Update docs

@dbu
Copy link
Member

dbu commented Feb 6, 2015

looks sane to me, and makes sense.

the only thing missing imo is a PR to adjust the doc, with a .. since to the configuration reference of the seo bundle.

@lsmith77
Copy link
Member

lsmith77 commented Feb 6, 2015

cc @ElectricMaxxx

@@ -85,6 +85,9 @@ public function getConfigTreeBuilder()
->scalarNode('enable_sibling_provider')->defaultValue(false)->end()
->end()
->end()
->arrayNode('content_listener')
->canBeDisabled()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, I think we should use a booleanNode and call it use_content_listener

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also possible. but if we ever want to have other configuration on content_listener, it will be unelegant. then again that is not too likely, so +1 for use_content_listener (without a content_listener array node)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually how I originally wrote it (booleanNode) however my thought was we may want to allow specifying a service_id to use instead of the out of the box content listener so you could provide your own content listener and not have to rewrite the alternate locale provider portion. I'm perfectly happy to switch it to a booleanNode, just figured I'd provide my rational first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we agree, I just wanted to point out that you can easily keep BC by keeping content_listener.enabled and use_content_listener in sync in case we want to add more config in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what about a content_listener setting (scalarNode) which could either be the service id or false/null to disable it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value would be thre service id of thre drfault listener.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this its more explicit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the bundle need to know the service id of the default listener? if yes that would be the right thing to do. although, would that mean that if its the default value, SeoBundle loads the service and otherwise its assumes the application provides the service somewhere else? and, does the SeoBundle need to know the name of that listener, does it inject it elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu I think the way this is handled by FOSUserBundle where you can override the service id for the user manager is that the default service's id is like cmf_seo.content_listener_default and the dependency injection extension sets up cmf_seo.content_listener as an alias based on the configuration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, sounds like a plan!

@wouterj
Copy link
Member

wouterj commented Feb 6, 2015

The XML schema needs to be updated too

@ElectricMaxxx
Copy link
Member

I think there a still some features missing in the xml schema :-(

@ElectricMaxxx
Copy link
Member

@benglass looks good to me,but can you add a test for both situations. Should be something like
https://github.com/symfony-cmf/SeoBundle/blob/master/Tests/Unit/DependencyInjection/CmfSeoExtensionTest.php#L119-L122
and entry into the ConfigurationTest too.

@ElectricMaxxx ElectricMaxxx mentioned this pull request Feb 17, 2015
@dbu
Copy link
Member

dbu commented Feb 17, 2015

@benglass any chance to wrap this up? we think about tagging a new minor version of SeoBundle this week to get the sitemap generation feature in a stable release.

'setAlternateLocaleProvider',
array($this->container->getDefinition('cmf_seo.alternate_locale.provider_phpcr'))
);
if ($this->container->has('cmf_seo.event_listener.seo_content')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wyh are you doing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this PR adds the ability to remove the seo content listener, therefore this test needs to only assert that the event listener exists with this method call if the event listener exists

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally the alternate locale provider is injected into the SeoPresentation, when activated and with phpcr as implementation, this is done inside of the CmfSeoExtension. I would propose to add your changes there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do then you should use the config section above of the test and check for the existence by on or many asserts. Cause i think your/my event listener will exist only, when there is a line in the configuration, right?

@benglass
Copy link
Member Author

@dbu @wouterj @ElectricMaxxx

I have now added tests and updated the xml schema. I do not have experience working with xsd files so can someone verify I did it correctly? The current schema file does not seem up to date with the other config values but I think you may have already fixed this in the master branch?

Doc PR will be coming but it would be great to get this merged in for a numbered release

@@ -39,4 +39,8 @@
<xsd:enumeration value="canonical" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="enable_content_listener">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes should be removed and instead, you should add this between line 20 and 21 in this file:

<xsd:attribute name="enable-content-listener" type="xsd:boolean" default="true" />

@wouterj
Copy link
Member

wouterj commented Feb 19, 2015

Thanks @benglass! Apart from my XSD comment, it looks great.

Could you please also rebase this PR? Then Travis can run a build and we can merge if Travis is happy :)

@benglass benglass force-pushed the allow_disabling_listener branch 2 times, most recently from b494402 to fb0f53a Compare February 19, 2015 18:17
@benglass benglass force-pushed the allow_disabling_listener branch from fb0f53a to 6458665 Compare February 19, 2015 18:21
@benglass
Copy link
Member Author

@wouterj Squashed, rebase and awaiting tests

@benglass
Copy link
Member Author

@wouterj @ElectricMaxxx @dantleech Tests passing ready for merge

@wouterj
Copy link
Member

wouterj commented Feb 19, 2015

👍

dbu added a commit that referenced this pull request Feb 20, 2015
@dbu dbu merged commit 16d38da into symfony-cmf:master Feb 20, 2015
@dbu
Copy link
Member

dbu commented Feb 20, 2015

thanks a lot! created an issue so we don't forget the documentation: symfony-cmf/symfony-cmf-docs#644

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants