Skip to content

Commit

Permalink
Move Url related functionality to separate Url namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Dec 30, 2023
1 parent b1fc720 commit 2e60127
Show file tree
Hide file tree
Showing 58 changed files with 364 additions and 313 deletions.
2 changes: 1 addition & 1 deletion services.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
imports:
- { resource: src/ChangeFilter/services.yaml }
- { resource: src/Command/services.yaml }
- { resource: src/PageType/services.yaml }
- { resource: src/Repository/services.yaml }
- { resource: src/Service/services.yaml }
- { resource: src/Settings/services.yaml }
- { resource: src/Url/services.yaml }

services:
_defaults:
Expand Down
10 changes: 4 additions & 6 deletions src/ChangeFilter/ChangeFilterTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ForwardCompatibility\Result;
use FreshAdvance\Sitemap\DataStructure\ObjectUrl;
use FreshAdvance\Sitemap\DataStructure\PageUrl;
use FreshAdvance\Sitemap\PageType\PageTypeConfigurationInterface;
use FreshAdvance\Sitemap\Repository\ModelItemRepositoryInterface;
use OxidEsales\EshopCommunity\Core\Contract\IUrl;
use OxidEsales\EshopCommunity\Core\Model\BaseModel;
use FreshAdvance\Sitemap\Url\DataType\UrlTypeInterface;
use Generator;
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface;

abstract class ChangeFilterTemplate
Expand All @@ -26,13 +24,13 @@ abstract class ChangeFilterTemplate

public function __construct(
ConnectionProviderInterface $connectionProvider,
protected PageTypeConfigurationInterface $pageTypeConfiguration,
protected UrlTypeInterface $pageTypeConfiguration,
protected ModelItemRepositoryInterface $modelItemRepository,
) {
$this->connection = $connectionProvider->get();
}

public function queryAndFetchObjectUrl(string $query, array $queryParameters): \Generator
public function queryAndFetchObjectUrl(string $query, array $queryParameters): Generator
{
/** @var Result $result */
$result = $this->connection->executeQuery(
Expand Down
6 changes: 3 additions & 3 deletions src/ChangeFilter/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ services:

FreshAdvance\Sitemap\ChangeFilter\ContentChangeFilter:
arguments:
$pageTypeConfiguration: '@FreshAdvance\Sitemap\PageType\ContentConfiguration'
$pageTypeConfiguration: '@FreshAdvance\Sitemap\Url\DataTypeFactory\ContentUrlType'
$modelItemRepository: '@FreshAdvance\Sitemap\Repository\ContentModelItemRepository'
tags:
- 'sitemap.change_filter'

FreshAdvance\Sitemap\ChangeFilter\ProductChangeFilter:
arguments:
$pageTypeConfiguration: '@FreshAdvance\Sitemap\PageType\ProductConfiguration'
$pageTypeConfiguration: '@FreshAdvance\Sitemap\Url\DataTypeFactory\ProductUrlType'
$modelItemRepository: '@FreshAdvance\Sitemap\Repository\ProductModelItemRepository'
tags:
- 'sitemap.change_filter'

FreshAdvance\Sitemap\ChangeFilter\CategoryChangeFilter:
arguments:
$pageTypeConfiguration: '@FreshAdvance\Sitemap\PageType\CategoryConfiguration'
$pageTypeConfiguration: '@FreshAdvance\Sitemap\Url\DataTypeFactory\CategoryUrlType'
$modelItemRepository: '@FreshAdvance\Sitemap\Repository\CategoryModelItemRepository'
tags:
- 'sitemap.change_filter'
1 change: 0 additions & 1 deletion src/Command/UpdateTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace FreshAdvance\Sitemap\Command;

use FreshAdvance\Sitemap\ChangeFilter\FilterFactoryInterface;
use FreshAdvance\Sitemap\Service\SynchronizerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down
6 changes: 4 additions & 2 deletions src/DataStructure/ObjectUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

namespace FreshAdvance\Sitemap\DataStructure;

use DateTimeInterface;

class ObjectUrl implements ObjectUrlInterface
{
public function __construct(
private string $objectId,
private string $objectType,
private string $location,
private \DateTimeInterface $modified,
private DateTimeInterface $modified,
) {
}

Expand All @@ -34,7 +36,7 @@ public function getLocation(): string
return $this->location;
}

public function getModified(): \DateTimeInterface
public function getModified(): DateTimeInterface
{
return $this->modified;
}
Expand Down
4 changes: 3 additions & 1 deletion src/DataStructure/ObjectUrlInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace FreshAdvance\Sitemap\DataStructure;

use DateTimeInterface;

interface ObjectUrlInterface
{
public function getObjectId(): string;
Expand All @@ -15,5 +17,5 @@ public function getObjectType(): string;

public function getLocation(): string;

public function getModified(): \DateTimeInterface;
public function getModified(): DateTimeInterface;
}
6 changes: 4 additions & 2 deletions src/DataStructure/SitemapUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

namespace FreshAdvance\Sitemap\DataStructure;

use DateTimeInterface;

class SitemapUrl implements SitemapUrlInterface
{
public function __construct(
protected string $location,
protected \DateTimeInterface $lastModified
protected DateTimeInterface $lastModified
) {
}

Expand All @@ -22,7 +24,7 @@ public function getLocation(): string
return $this->location;
}

public function getLastModified(): \DateTimeInterface
public function getLastModified(): DateTimeInterface
{
return $this->lastModified;
}
Expand Down
4 changes: 3 additions & 1 deletion src/DataStructure/SitemapUrlInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

namespace FreshAdvance\Sitemap\DataStructure;

use DateTimeInterface;

interface SitemapUrlInterface
{
public function getLocation(): string;

public function getLastModified(): \DateTimeInterface;
public function getLastModified(): DateTimeInterface;
}
4 changes: 3 additions & 1 deletion src/Exception/FilterConfigurationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace FreshAdvance\Sitemap\Exception;

class FilterConfigurationException extends \Exception
use Exception;

class FilterConfigurationException extends Exception
{
}
4 changes: 3 additions & 1 deletion src/Exception/FilterNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace FreshAdvance\Sitemap\Exception;

class FilterNotFoundException extends \Exception
use Exception;

class FilterNotFoundException extends Exception
{
}
4 changes: 3 additions & 1 deletion src/Exception/ModelItemNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace FreshAdvance\Sitemap\Exception;

class ModelItemNotFoundException extends \Exception
use Exception;

class ModelItemNotFoundException extends Exception
{
}
4 changes: 3 additions & 1 deletion src/Exception/SitemapDirectoryAccessException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace FreshAdvance\Sitemap\Exception;

class SitemapDirectoryAccessException extends \Exception
use Exception;

class SitemapDirectoryAccessException extends Exception
{
}
39 changes: 0 additions & 39 deletions src/PageType/PageTypeConfigurationFactory.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/PageType/PageTypeConfigurationFactoryInterface.php

This file was deleted.

45 changes: 0 additions & 45 deletions src/PageType/services.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions src/Repository/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ services:
class: FreshAdvance\Sitemap\Repository\ModelItemRepository
arguments:
$model: '\OxidEsales\Eshop\Application\Model\Content'

FreshAdvance\Sitemap\Repository\UrlRepositoryInterface:
class: FreshAdvance\Sitemap\Repository\UrlRepository
2 changes: 1 addition & 1 deletion src/Service/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace FreshAdvance\Sitemap\Service;

use FreshAdvance\Sitemap\DataStructure\SitemapUrlInterface;
use FreshAdvance\Sitemap\Repository\UrlRepositoryInterface;
use FreshAdvance\Sitemap\Settings\LocationServiceInterface;
use FreshAdvance\Sitemap\Url\Repository\UrlRepositoryInterface;

class Sitemap implements SitemapInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Synchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace FreshAdvance\Sitemap\Service;

use FreshAdvance\Sitemap\ChangeFilter\FilterFactoryInterface;
use FreshAdvance\Sitemap\Repository\UrlRepositoryInterface;
use FreshAdvance\Sitemap\Url\Repository\UrlRepositoryInterface;

class Synchronizer implements SynchronizerInterface
{
Expand Down
17 changes: 0 additions & 17 deletions src/Service/UrlFactoryInterface.php

This file was deleted.

9 changes: 5 additions & 4 deletions src/Service/XmlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@

namespace FreshAdvance\Sitemap\Service;

use FreshAdvance\Sitemap\DataStructure\PageUrlInterface;
use DateTimeInterface;
use FreshAdvance\Sitemap\DataStructure\SitemapUrlInterface;
use FreshAdvance\Sitemap\Url\DataType\UrlInterface;

class XmlGenerator implements XmlGeneratorInterface
{
public function generateUrlItem(PageUrlInterface $url): string
public function generateUrlItem(UrlInterface $url): string
{
$attributes = [
$this->wrap($url->getLocation(), "loc"),
$this->wrap($url->getLastModified()->format(\DateTimeInterface::ATOM), "lastmod"),
$this->wrap($url->getLastModified()->format(DateTimeInterface::ATOM), "lastmod"),
$this->wrap($url->getChangeFrequency(), "changefreq"),
$this->wrap((string)$url->getPriority(), "priority"),
];
Expand All @@ -30,7 +31,7 @@ public function generateSitemapItem(SitemapUrlInterface $url): string
{
$attributes = [
$this->wrap($url->getLocation(), "loc"),
$this->wrap($url->getLastModified()->format(\DateTimeInterface::ATOM), "lastmod"),
$this->wrap($url->getLastModified()->format(DateTimeInterface::ATOM), "lastmod"),
];

return $this->wrap(implode("", $attributes), "sitemap");
Expand Down
4 changes: 2 additions & 2 deletions src/Service/XmlGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace FreshAdvance\Sitemap\Service;

use FreshAdvance\Sitemap\DataStructure\PageUrlInterface;
use FreshAdvance\Sitemap\DataStructure\SitemapUrlInterface;
use FreshAdvance\Sitemap\Url\DataType\UrlInterface;

interface XmlGeneratorInterface
{
/**
* @param iterable<PageUrlInterface> $items
* @param iterable<UrlInterface> $items
*/
public function generateSitemapDocument(iterable $items): string;

Expand Down
3 changes: 0 additions & 3 deletions src/Service/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ services:
FreshAdvance\Sitemap\Service\SynchronizerInterface:
class: FreshAdvance\Sitemap\Service\Synchronizer

FreshAdvance\Sitemap\Service\UrlFactoryInterface:
class: FreshAdvance\Sitemap\Service\UrlFactory

FreshAdvance\Sitemap\Service\XmlGeneratorInterface:
class: FreshAdvance\Sitemap\Service\XmlGenerator
Loading

0 comments on commit 2e60127

Please sign in to comment.