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

support for additional document properties #5

Open
wants to merge 3 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

support for additional document properties

  • Loading branch information...
bmeynell committed Apr 24, 2014
commit ad4d53a9024c43e67fda7322ba15352f2cbc9adc
@@ -34,8 +34,9 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('sitemap.xml');
$defaults = $container->getParameter('opensky.sitemap.defaults');
$properties = array_merge(array('changefreq', 'priority', 'lastmod'), $container->getParameter('opensky.sitemap.properties'));
foreach ($configs as $config) {
foreach (array('changefreq', 'priority', 'lastmod') as $prop) {
foreach ($properties as $prop) {
if (isset($config['default_' . $prop])) {
$defaults[$prop] = $config['default_' . $prop];
}
@@ -53,4 +54,4 @@ public function getAlias()
{
return 'opensky_sitemap';
}
}
}
@@ -15,13 +15,15 @@
<parameter key="opensky.sitemap.template.engine">twig</parameter>
<parameter key="opensky.sitemap.defaults" type="collection" />
<parameter key="opensky.sitemap.providers" type="collection" />
<parameter key="opensky.sitemap.properties" type="collection" />
</parameters>

<services>
<service alias="opensky.sitemap.sitemap" id="opensky.sitemap" />
<service id="opensky.sitemap.sitemap" class="%opensky.sitemap.class%">
<argument type="service" id="opensky.sitemap.sitemap.storage" />
<argument>%opensky.sitemap.defaults%</argument>
<argument>%opensky.sitemap.properties%</argument>
<call method="setUrlClass">
<argument>%opensky.sitemap.url.class%</argument>
</call>
@@ -42,4 +44,4 @@
<argument type="service" id="opensky.sitemap.dumper" />
</service>
</services>
</container>
</container>
@@ -22,6 +22,10 @@ class Sitemap
* @var array
*/
protected $defaults = array();
/**
* @var array
*/
protected $properties = array();
/**
* @var OpenSky\Bundle\SitemapBundle\Sitemap\Storage\Storage
*/
@@ -31,10 +35,11 @@ class Sitemap
* @param OpenSky\Bundle\SitemapBundle\Sitemap\Storage\Storage $storage
* @param array $defaults
*/
public function __construct(Storage $storage, array $defaults = array())
public function __construct(Storage $storage, array $defaults = array(), array $properties = array())
{
$this->storage = $storage;
foreach (array('changefreq', 'priority', 'lastmod') as $prop) {
$this->properties = array_merge(array('changefreq', 'priority', 'lastmod'), $properties);
foreach ($this->properties as $prop) {
if (isset($defaults[$prop])) {
$this->defaults[$prop] = $defaults[$prop];
}
@@ -68,7 +73,7 @@ public function add($loc, array $info)
$info = array_merge($this->defaults, $info);
$urlClass = $this->getUrlClass();
$url = new $urlClass($loc);
foreach (array('changefreq', 'priority', 'lastmod') as $prop) {
foreach ($this->properties as $prop) {
if (isset($info[$prop])) {
$url->{'set' . ucfirst($prop)}($info[$prop]);
}
@@ -122,4 +127,4 @@ public function getStorage()
return $this->storage;
}
}
}
@@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": ">=5.3.0",
"symfony/framework-bundle": ">=2.1.0,<2.3-dev"
"symfony/framework-bundle": ">=2.1.0,<2.4-dev"
},
"autoload": {
"psr-0": { "OpenSky\\Bundle\\SitemapBundle": "" }
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.