-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract page type configurations from Filters
Signed-off-by: Anton Fedurtsya <[email protected]>
- Loading branch information
Showing
18 changed files
with
288 additions
and
58 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
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
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
14 changes: 14 additions & 0 deletions
14
src/Exception/PageTypeConfigurationFactorySetupException.php
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,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\Exception; | ||
|
||
class PageTypeConfigurationFactorySetupException extends \Exception | ||
{ | ||
} |
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,35 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\PageType; | ||
|
||
class PageTypeConfiguration implements PageTypeConfigurationInterface | ||
{ | ||
public function __construct( | ||
protected string $objectType, | ||
protected string $changeFrequency, | ||
protected float $priority | ||
) { | ||
} | ||
|
||
public function getObjectType(): string | ||
{ | ||
return $this->objectType; | ||
} | ||
|
||
public function getChangeFrequency(): string | ||
{ | ||
return $this->changeFrequency; | ||
} | ||
|
||
public function getPriority(): float | ||
{ | ||
return $this->priority; | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\PageType; | ||
|
||
use FreshAdvance\Sitemap\Exception\PageTypeConfigurationFactorySetupException; | ||
|
||
class PageTypeConfigurationFactory implements PageTypeConfigurationFactoryInterface | ||
{ | ||
protected array $configurations = []; | ||
|
||
/** | ||
* @param iterable<PageTypeConfigurationInterface> $configurations | ||
* @throws PageTypeConfigurationFactorySetupException | ||
*/ | ||
public function __construct( | ||
iterable $configurations, | ||
protected PageTypeConfigurationInterface $defaultConfiguration | ||
) { | ||
foreach ($configurations as $oneConfiguration) { | ||
if (!$oneConfiguration instanceof PageTypeConfigurationInterface) { | ||
throw new PageTypeConfigurationFactorySetupException(); | ||
} | ||
|
||
$this->configurations[$oneConfiguration->getObjectType()] = $oneConfiguration; | ||
} | ||
} | ||
|
||
public function getConfiguration(string $string): PageTypeConfigurationInterface | ||
{ | ||
return $this->configurations[$string] ?? $this->defaultConfiguration; | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\PageType; | ||
|
||
interface PageTypeConfigurationFactoryInterface | ||
{ | ||
public function getConfiguration(string $string): PageTypeConfigurationInterface; | ||
} |
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,19 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\PageType; | ||
|
||
interface PageTypeConfigurationInterface | ||
{ | ||
public function getObjectType(): string; | ||
|
||
public function getChangeFrequency(): string; | ||
|
||
public function getPriority(): float; | ||
} |
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,45 @@ | ||
services: | ||
|
||
_defaults: | ||
public: false | ||
autowire: true | ||
|
||
FreshAdvance\Sitemap\PageType\PageTypeConfigurationFactoryInterface: | ||
class: FreshAdvance\Sitemap\PageType\PageTypeConfigurationFactory | ||
arguments: | ||
$configurations: !tagged 'sitemap.page_type_configuration' | ||
$defaultConfiguration: '@FreshAdvance\Sitemap\PageType\DefaultConfiguration' | ||
|
||
FreshAdvance\Sitemap\PageType\DefaultConfiguration: | ||
class: FreshAdvance\Sitemap\PageType\PageTypeConfiguration | ||
arguments: | ||
$objectType: 'default' | ||
$changeFrequency: 'daily' | ||
$priority: 0.5 | ||
|
||
FreshAdvance\Sitemap\PageType\ProductConfiguration: | ||
class: FreshAdvance\Sitemap\PageType\PageTypeConfiguration | ||
arguments: | ||
$objectType: 'product' | ||
$changeFrequency: 'daily' | ||
$priority: 0.4 | ||
tags: | ||
- 'sitemap.page_type_configuration' | ||
|
||
FreshAdvance\Sitemap\PageType\CategoryConfiguration: | ||
class: FreshAdvance\Sitemap\PageType\PageTypeConfiguration | ||
arguments: | ||
$objectType: 'category' | ||
$changeFrequency: 'daily' | ||
$priority: 0.7 | ||
tags: | ||
- 'sitemap.page_type_configuration' | ||
|
||
FreshAdvance\Sitemap\PageType\ContentConfiguration: | ||
class: FreshAdvance\Sitemap\PageType\PageTypeConfiguration | ||
arguments: | ||
$objectType: 'content' | ||
$changeFrequency: 'weekly' | ||
$priority: 0.3 | ||
tags: | ||
- 'sitemap.page_type_configuration' |
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
Oops, something went wrong.