Skip to content

Commit c6a6b2c

Browse files
committed
Cleanup
1 parent 633781f commit c6a6b2c

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

src/Sitemap/Provider/PageUrlProvider.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?php
22

3+
/*
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* another great project.
7+
* You can find more information about us on https://bitbag.shop and write us
8+
* an email on mikolaj.krol@bitbag.pl.
9+
*/
10+
311
declare(strict_types=1);
412

513
namespace BitBag\SyliusCmsPlugin\Sitemap\Provider;
@@ -136,6 +144,7 @@ private function getLocaleCodes(): array
136144
if (null === $this->channelLocaleCodes) {
137145
/** @var ChannelInterface $channel */
138146
$channel = $this->channelContext->getChannel();
147+
139148
$this->channelLocaleCodes = $channel->getLocales()->map(function (LocaleInterface $locale) {
140149
return $locale->getCode();
141150
})->toArray();
@@ -152,30 +161,37 @@ private function getLocaleCodes(): array
152161
private function createPageUrl(PageInterface $page): SitemapUrlInterface
153162
{
154163
$pageUrl = $this->sitemapUrlFactory->createNew();
164+
155165
$pageUrl->setChangeFrequency(ChangeFrequency::daily());
156166
$pageUrl->setPriority(0.7);
167+
157168
if ($page->getUpdatedAt()) {
158169
$pageUrl->setLastModification($page->getUpdatedAt());
159170
} elseif ($page->getCreatedAt()) {
160171
$pageUrl->setLastModification($page->getCreatedAt());
161172
}
173+
162174
/** @var PageTranslationInterface $translation */
163175
foreach ($this->getTranslations($page) as $translation) {
164176
if (!$translation->getLocale()) {
165177
continue;
166178
}
179+
167180
if (!$this->localeInLocaleCodes($translation)) {
168181
continue;
169182
}
183+
170184
$location = $this->router->generate('bitbag_sylius_cms_plugin_shop_page_show', [
171185
'slug' => $translation->getSlug(),
172186
'_locale' => $translation->getLocale(),
173187
]);
188+
174189
if ($translation->getLocale() === $this->localeContext->getLocaleCode()) {
175190
$pageUrl->setLocalization($location);
176191

177192
continue;
178193
}
194+
179195
$pageUrl->addAlternative($location, $translation->getLocale());
180196
}
181197

tests/Api/Sitemap/Provider/AbstractTestController.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/*
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* another great project.
7+
* You can find more information about us on https://bitbag.shop and write us
8+
* an email on mikolaj.krol@bitbag.pl.
9+
*/
10+
11+
declare(strict_types=1);
12+
313
namespace Tests\BitBag\SyliusCmsPlugin\Api\Sitemap\Provider;
414

515
use Lakion\ApiTestCase\XmlApiTestCase;
@@ -12,7 +22,6 @@
1222

1323
abstract class AbstractTestController extends XmlApiTestCase
1424
{
15-
1625
/**
1726
* @var ChannelInterface
1827
*/
@@ -35,8 +44,10 @@ abstract class AbstractTestController extends XmlApiTestCase
3544

3645
/**
3746
* @before
47+
*
48+
* {@inheritdoc}
3849
*/
39-
public function setupDatabase()
50+
public function setupDatabase(): void
4051
{
4152
parent::setUpDatabase();
4253

@@ -68,5 +79,4 @@ public function setupDatabase()
6879
$this->getEntityManager()->persist($this->channel);
6980
$this->getEntityManager()->flush();
7081
}
71-
7282
}

tests/Api/Sitemap/Provider/SitemapPageControllerApiLocalesTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
<?php
22

3+
/*
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* another great project.
7+
* You can find more information about us on https://bitbag.shop and write us
8+
* an email on mikolaj.krol@bitbag.pl.
9+
*/
10+
11+
declare(strict_types=1);
12+
313
namespace Tests\BitBag\SyliusCmsPlugin\Api\Sitemap\Provider;
414

515
use BitBag\SyliusCmsPlugin\Entity\Page;
616

717
class SitemapPageControllerApiLocalesTest extends AbstractTestController
818
{
9-
1019
/**
1120
* @before
21+
*
22+
* {@inheritdoc}
1223
*/
13-
public function setUpDatabase()
24+
public function setUpDatabase(): void
1425
{
1526
parent::setUpDatabase();
1627

@@ -63,11 +74,10 @@ public function setUpDatabase()
6374
$this->getEntityManager()->flush();
6475
}
6576

66-
public function testShowActionResponse()
77+
public function testShowActionResponse(): void
6778
{
6879
$this->client->request('GET', '/sitemap/cms_pages.xml');
6980
$response = $this->client->getResponse();
7081
$this->assertResponse($response, 'show_sitemap_pages_locale');
7182
}
72-
7383
}

tests/Api/Sitemap/Provider/SitemapPageControllerApiTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
<?php
22

3+
/*
4+
* This file has been created by developers from BitBag.
5+
* Feel free to contact us once you face any issues or want to start
6+
* another great project.
7+
* You can find more information about us on https://bitbag.shop and write us
8+
* an email on mikolaj.krol@bitbag.pl.
9+
*/
10+
11+
declare(strict_types=1);
12+
313
namespace Tests\BitBag\SyliusCmsPlugin\Api\Sitemap\Provider;
414

515
use BitBag\SyliusCmsPlugin\Entity\Page;
616

717
class SitemapPageControllerApiTest extends AbstractTestController
818
{
9-
1019
/**
1120
* @before
21+
*
22+
* {@inheritdoc}
1223
*/
13-
public function setUpDatabase()
24+
public function setUpDatabase(): void
1425
{
1526
parent::setUpDatabase();
1627

@@ -20,12 +31,14 @@ public function setUpDatabase()
2031
$page->setCode('test-code');
2132
$page->setSlug('test');
2233
$this->getEntityManager()->persist($page);
34+
2335
$page = new Page();
2436
$page->setCurrentLocale('en_US');
2537
$page->setName('Mock');
2638
$page->setCode('mock-code');
2739
$page->setSlug('mock');
2840
$this->getEntityManager()->persist($page);
41+
2942
$page = new Page();
3043
$page->setCurrentLocale('en_US');
3144
$page->setName('Test 2');
@@ -36,11 +49,10 @@ public function setUpDatabase()
3649
$this->getEntityManager()->flush();
3750
}
3851

39-
public function testShowActionResponse()
52+
public function testShowActionResponse(): void
4053
{
4154
$this->client->request('GET', '/sitemap/cms_pages.xml');
4255
$response = $this->client->getResponse();
4356
$this->assertResponse($response, 'show_sitemap_pages');
4457
}
45-
4658
}

0 commit comments

Comments
 (0)