Skip to content

Commit

Permalink
Implement dummy sitemap generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
igor committed Feb 20, 2016
1 parent e2c83bb commit 3f9f9f2
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Exception/DarvinSitemapException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @author Igor Nikolaev <[email protected]>
* @copyright Copyright (c) 2016, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Exception;

/**
* Base exception
*/
class DarvinSitemapException extends \Exception
{

}
21 changes: 21 additions & 0 deletions Generator/GeneratorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @author Igor Nikolaev <[email protected]>
* @copyright Copyright (c) 2016, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Generator;

use Darvin\SitemapBundle\Exception\DarvinSitemapException;

/**
* Sitemap generator exception
*/
class GeneratorException extends DarvinSitemapException
{

}
54 changes: 54 additions & 0 deletions Generator/SitemapGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @author Igor Nikolaev <[email protected]>
* @copyright Copyright (c) 2016, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Generator;

use Darvin\SitemapBundle\Url\SitemapUrlProviderInterface;

/**
* Sitemap generator
*/
class SitemapGenerator implements SitemapGeneratorInterface
{
/**
* @var \Darvin\SitemapBundle\Url\SitemapUrlProviderInterface[]
*/
private $urlProviders;

/**
* Constructor
*/
public function __construct()
{
$this->urlProviders = array();
}

/**
* {@inheritdoc}
*/
public function addUrlProvider(SitemapUrlProviderInterface $urlProvider)
{
$class = get_class($urlProvider);

if (isset($this->urlProviders[$class])) {
throw new GeneratorException(sprintf('Sitemap URL provider "%s" already added to sitemap generator.', $class));
}

$this->urlProviders[$class] = $urlProvider;
}

/**
* {@inheritdoc}
*/
public function generateSitemap()
{
// TODO: Implement generateSitemap() method.
}
}
29 changes: 29 additions & 0 deletions Generator/SitemapGeneratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* @author Igor Nikolaev <[email protected]>
* @copyright Copyright (c) 2016, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Generator;

use Darvin\SitemapBundle\Url\SitemapUrlProviderInterface;

/**
* Sitemap generator
*/
interface SitemapGeneratorInterface
{
/**
* @param \Darvin\SitemapBundle\Url\SitemapUrlProviderInterface $urlProvider Sitemap URL provider
*/
public function addUrlProvider(SitemapUrlProviderInterface $urlProvider);

/**
* @return string
*/
public function generateSitemap();
}
2 changes: 1 addition & 1 deletion Sitemap/SitemapUrl.php → Url/SitemapUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Sitemap;
namespace Darvin\SitemapBundle\Url;

use Symfony\Component\Validator\Constraints as Assert;

Expand Down
22 changes: 22 additions & 0 deletions Url/SitemapUrlProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @author Igor Nikolaev <[email protected]>
* @copyright Copyright (c) 2016, Darvin Studio
* @link https://www.darvin-studio.ru
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Darvin\SitemapBundle\Url;

/**
* Sitemap URL provider
*/
interface SitemapUrlProviderInterface
{
/**
* @return \Darvin\SitemapBundle\Url\SitemapUrl[]
*/
public function getSitemapUrls();
}

0 comments on commit 3f9f9f2

Please sign in to comment.