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

(sitemap) Templates in config #217

Closed
wants to merge 3 commits into from

Conversation

Peekmo
Copy link
Contributor

@Peekmo Peekmo commented Feb 17, 2015

Hello,

To be able to override or add some templates, I added the key "templates" in config (much cleaner I suppose).
Let me know if something is wrong with it :)

Regards,
Peekmo

->arrayNode('templates')
->addDefaultsIfNotSet()
->children()
->scalarNode('xml')->defaultValue('CmfSeoBundle:Sitemap:index.xml.twig')->end()
Copy link
Member

Choose a reason for hiding this comment

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

i think this should be an array with the format as key, so that users can add even keys that the bundle knows nothing about. the controller is built that way. the format should look like this: https://github.com/symfony-cmf/RoutingBundle/blob/master/DependencyInjection/Configuration.php#L41-L45 but with useAttributeAsKey('format')

not sure if we can put the defaults in the Configuration class in this case - maybe something like ->beforeNormalization()->ifEmpty()->then(function ($v) { return array('xml' => ...); })->end() (did not test this so might not work exactly like this)

Copy link
Member

Choose a reason for hiding this comment

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

+1 for a prototyped array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree too, I'll test if default value in this case can work

@dbu
Copy link
Member

dbu commented Feb 17, 2015

although overwriting templates would be fine in this case, i think this idea is right because it allows to add aditional formats (e.g. a template for json, or for a custom sitemap format)

@ElectricMaxxx
Copy link
Member

What is wrong with overwriting templates by the simple "symfony way"?

@wouterj
Copy link
Member

wouterj commented Feb 17, 2015

@ElectricMaxxx ability to add custom formats (when using a prototyped array)

@ElectricMaxxx
Copy link
Member

You can add what you whant when injecting it into the service defintion. But you yould probably right, using that parameter array, injecting that is easier to use.

@dbu
Copy link
Member

dbu commented Feb 17, 2015

@ElectricMaxxx as is, one would have to write a compiler pass to change the service definition. a configuration option is more convenient

@ElectricMaxxx
Copy link
Member

👍

(Btw: i think i have had it that way somewhere in the Monster PR g)

@ElectricMaxxx
Copy link
Member

You know how to work on that PR or need some help?

@Peekmo
Copy link
Contributor Author

Peekmo commented Feb 18, 2015

This one works, but I don't know how (for example) to keep 'xml' default value if the html one is overrided.

@@ -90,6 +90,15 @@ public function getConfigTreeBuilder()
->canBeEnabled()
->children()
->scalarNode('default_chan_frequency')->defaultValue('always')->end()
->arrayNode('templates')
Copy link
Member

Choose a reason for hiding this comment

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

you should add ->fixXmlConfig('template') before line 91

@ElectricMaxxx
Copy link
Member

I would like to skip that one here, cause i will re-implement it when introducing named sitemaps and its values (templates, enhancers, ...) in #221

@dbu dbu mentioned this pull request Feb 19, 2015
6 tasks
@dbu
Copy link
Member

dbu commented Jul 28, 2015

i ported this into master, now that the refactoring happened. @Peekmo please have a look at master and open a new issue if you think there is something still missing. thanks for the contribution!

@dbu dbu closed this Jul 28, 2015
@lsmith77 lsmith77 removed the review label Jul 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants