forked from avalanche123/AvalancheSitemapBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP to allow usage without Doctrine ODM
- Loading branch information
Showing
8 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Avalanche\Bundle\SitemapBundle\Command; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Avalanche\Bundle\SitemapBundle\Sitemap\Provider; | ||
|
||
class PopulateCommand extends ContainerAwareCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setName('sitemap:populate') | ||
->setDescription('Populate sitemap, using its data providers.'); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$sitemap = $this->getContainer()->get('sitemap'); | ||
|
||
$this->getContainer()->get('sitemap.provider.chain')->populate($sitemap); | ||
$output->write('<info>Sitemap was sucessfully populated!</info>', true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Avalanche\Bundle\SitemapBundle\Document; | ||
|
||
use Avalanche\Bundle\SitemapBundle\Sitemap\Url; | ||
use Avalanche\Bundle\SitemapBundle\Sitemap\UrlRepositoryInterface; | ||
|
||
class ArrayUrlRepository implements UrlRepositoryInterface | ||
{ | ||
private $urls = array(); | ||
|
||
public function add(Url $url) | ||
{ | ||
$this->urls[$url->getLoc()] = $url; | ||
} | ||
|
||
public function findAllOnPage($page) | ||
{ | ||
return array_slice( | ||
$this->urls, | ||
UrlRepositoryInterface::PER_PAGE_LIMIT * ($page - 1), | ||
UrlRepositoryInterface::PER_PAGE_LIMIT, | ||
true | ||
); | ||
} | ||
|
||
public function findOneByLoc($loc) | ||
{ | ||
$url = null; | ||
if (isset($this->urls[$loc])) { | ||
$url = $this->urls[$loc]; | ||
} | ||
return $url; | ||
} | ||
|
||
public function remove(Url $url) | ||
{ | ||
unset($this->urls[$url->getLoc()]); | ||
} | ||
|
||
public function pages() | ||
{ | ||
return max(ceil(count($this->urls) / UrlRepositoryInterface::PER_PAGE_LIMIT), 1); | ||
} | ||
|
||
public function flush() | ||
{ | ||
} | ||
|
||
public function getLastmod($page) | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<loc>{{ url('sitemap', { 'page': page }) }}</loc> | ||
<loc>{{ path('sitemap', { 'page': page })|sm_absolutize }}</loc> | ||
{% if sitemap.lastmod(page) %} | ||
<lastmod>sitemap.lastmod(page)|sm_format_date</lastmod> | ||
{% endif %} |