From c16c410b310d5b4fc0b4e6cc9ee31b351120b53f Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Fri, 27 May 2016 09:18:15 +0200 Subject: [PATCH 1/5] Remove Trailing Semicolon on Short Echo PHP Tags No need for these tags Signed-off-by: Justin Yost --- src/Template/Sitemaps/index.ctp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Template/Sitemaps/index.ctp b/src/Template/Sitemaps/index.ctp index 3f04b5a..3919a19 100644 --- a/src/Template/Sitemaps/index.ctp +++ b/src/Template/Sitemaps/index.ctp @@ -25,16 +25,16 @@ - _loc); ?> + _loc) ?> - _priority); ?> + _priority) ?> - _changefreq); ?> + _changefreq) ?> - _lastmod); ?> + _lastmod) ?> From bcd56f3b736a8054124247d0de7c4e923f9eb4a5 Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Fri, 27 May 2016 10:02:10 +0200 Subject: [PATCH 2/5] Adds Additional Router Params For Handling More Cases Signed-off-by: Justin Yost --- src/Model/Behavior/SitemapBehavior.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Model/Behavior/SitemapBehavior.php b/src/Model/Behavior/SitemapBehavior.php index 9f9ef2a..cd4af48 100644 --- a/src/Model/Behavior/SitemapBehavior.php +++ b/src/Model/Behavior/SitemapBehavior.php @@ -68,6 +68,8 @@ public function initialize(array $config) { public function returnUrlForEntity(Entity $entity) { return Router::url( [ + 'plugin' => null, + 'prefix' => null, 'controller' => $this->_table->registryAlias(), 'action' => 'view', $entity->{$this->_table->primaryKey()}, From 2296f0147803837597c2ade5515d48e3b160a379 Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Fri, 27 May 2016 10:03:06 +0200 Subject: [PATCH 3/5] Extend AppController Rather Than Core Controller Closes Issue #34 Signed-off-by: Justin Yost --- src/Controller/AppController.php | 4 ++-- tests/bootstrap.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index ab57ba4..e96dba0 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -4,10 +4,10 @@ */ namespace Sitemap\Controller; -use Cake\Controller\Controller; +use App\Controller\AppController as BaseController; /** * \Sitemap\Controller\AppController */ -class AppController extends Controller { +class AppController extends BaseController { } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2c0a150..db8cb67 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -73,3 +73,5 @@ 'quoteIdentifiers' => true, 'cacheMetadata' => true, ]); + +class_alias('Cake\Controller\Controller', 'App\Controller\AppController'); From 7da2984c4099a6d0d13d5aaa8d8d3e2f5bd4adb4 Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Fri, 27 May 2016 10:03:32 +0200 Subject: [PATCH 4/5] Add Basic XML Sitemap Support Closes Issue #30 Signed-off-by: Justin Yost --- config/routes.php | 1 + src/Template/Sitemaps/xml/index.ctp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/Template/Sitemaps/xml/index.ctp diff --git a/config/routes.php b/config/routes.php index c3a8ee9..88e8ee2 100644 --- a/config/routes.php +++ b/config/routes.php @@ -5,6 +5,7 @@ 'Sitemap', ['path' => '/sitemap'], function ($routes) { + $routes->extensions(['xml']); $routes->fallbacks('DashedRoute'); } ); diff --git a/src/Template/Sitemaps/xml/index.ctp b/src/Template/Sitemaps/xml/index.ctp new file mode 100644 index 0000000..6361859 --- /dev/null +++ b/src/Template/Sitemaps/xml/index.ctp @@ -0,0 +1,22 @@ + + + $dataForKey): ?> + + + + + _loc) ?> + + + _lastmod) ?> + + + _changefreq) ?> + + + _priority) ?> + + + + + From 6e516b3afcdb49bc77ee8a55259f0bc7f35e7ee9 Mon Sep 17 00:00:00 2001 From: Justin Yost Date: Fri, 27 May 2016 11:31:01 +0200 Subject: [PATCH 5/5] Code Sniff Fixes Signed-off-by: Justin Yost --- src/Model/Behavior/SitemapBehavior.php | 3 ++- tests/TestCase/Controller/SitemapsControllerTest.php | 3 ++- tests/TestCase/Model/Behavior/SitemapBehaviorTest.php | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Model/Behavior/SitemapBehavior.php b/src/Model/Behavior/SitemapBehavior.php index cd4af48..603848f 100644 --- a/src/Model/Behavior/SitemapBehavior.php +++ b/src/Model/Behavior/SitemapBehavior.php @@ -4,6 +4,7 @@ */ namespace Sitemap\Model\Behavior; +use Cake\Datasource\ResultSetInterface; use Cake\ORM\Behavior; use Cake\ORM\Entity; use Cake\ORM\Query; @@ -110,7 +111,7 @@ public function findSitemapRecords(Query $query, array $options) { * @return \Cake\Collection\CollectionInterface Returns the modified collection * of Results. */ - public function mapResults(\Cake\Datasource\ResultSetInterface $results) { + public function mapResults(ResultSetInterface $results) { return $results->map(function ($entity) { return $this->mapEntity($entity); }); diff --git a/tests/TestCase/Controller/SitemapsControllerTest.php b/tests/TestCase/Controller/SitemapsControllerTest.php index d3068ef..9ed569b 100644 --- a/tests/TestCase/Controller/SitemapsControllerTest.php +++ b/tests/TestCase/Controller/SitemapsControllerTest.php @@ -4,6 +4,7 @@ */ namespace Sitemap\Test\TestCase\Controller; +use Cake\Core\Configure; use Cake\ORM\TableRegistry; use Cake\TestSuite\IntegrationTestCase; use Sitemap\Controller\SitemapsController; @@ -81,7 +82,7 @@ public function testIndexNoModels() { * @covers \Sitemap\Controller\SitemapsController::index */ public function testIndexWithModels() { - \Cake\Core\Configure::write('Sitemap.tables', ['Pages']); + Configure::write('Sitemap.tables', ['Pages']); $pagesFindQuery = $this->Pages->find('forSitemap'); $Controller = $this->getMock( diff --git a/tests/TestCase/Model/Behavior/SitemapBehaviorTest.php b/tests/TestCase/Model/Behavior/SitemapBehaviorTest.php index b466b8c..aaa8e77 100644 --- a/tests/TestCase/Model/Behavior/SitemapBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/SitemapBehaviorTest.php @@ -5,6 +5,7 @@ namespace Sitemap\Test\TestCase\Model\Behavior; use Cake\Datasource\ConnectionManager; +use Cake\I18n\Time; use Cake\ORM\Entity; use Cake\ORM\Table; use Cake\ORM\TableRegistry; @@ -209,7 +210,7 @@ public function testMapEntity() { ); $this->assertEquals( - new \Cake\I18n\Time('2015-10-08 21:27:04'), + new Time('2015-10-08 21:27:04'), $entity->_lastmod, 'The _loc field should be set to our standard url' ); @@ -243,7 +244,7 @@ public function testMapEntity() { ); $this->assertEquals( - new \Cake\I18n\Time('2015-10-08 21:27:04'), + new Time('2015-10-08 21:27:04'), $entity->_lastmod, 'The _loc field should be set to our standard url' );