-
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.
Signed-off-by: Anton Fedurtsya <[email protected]>
- Loading branch information
Showing
8 changed files
with
135 additions
and
92 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,65 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © MB Arbatos Klubas. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FreshAdvance\Sitemap\ChangeFilter; | ||
|
||
use DateTime; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\ForwardCompatibility\Result; | ||
use FreshAdvance\Sitemap\DataStructure\ObjectUrl; | ||
use FreshAdvance\Sitemap\DataStructure\PageUrl; | ||
use OxidEsales\EshopCommunity\Core\Contract\IUrl; | ||
use OxidEsales\EshopCommunity\Core\Model\BaseModel; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface; | ||
|
||
abstract class ChangeFilterTemplate | ||
{ | ||
protected Connection $connection; | ||
|
||
public function __construct( | ||
ConnectionProviderInterface $connectionProvider | ||
) { | ||
$this->connection = $connectionProvider->get(); | ||
} | ||
|
||
abstract public function getObjectType(): string; | ||
|
||
public function getUpdatedUrls(int $limit): iterable | ||
{ | ||
$result = $this->filterAndQueryItems($limit); | ||
|
||
while ($data = $result->fetchAssociative()) { | ||
/** @var IUrl&BaseModel $item */ | ||
$item = oxNew($this->getModelClass()); | ||
$item->load((string)$data['OXID']); // @phpstan-ignore-line | ||
|
||
yield new ObjectUrl( | ||
objectId: $item->getId(), | ||
objectType: $this->getObjectType(), | ||
url: new PageUrl( | ||
location: (string)$item->getLink(), | ||
lastModified: new DateTime($item->getFieldData('oxtimestamp')), // @phpstan-ignore-line | ||
changeFrequency: $this->getChangeFrequency(), | ||
priority: $this->getPriority() | ||
) | ||
); | ||
} | ||
} | ||
|
||
abstract protected function filterAndQueryItems(int $limit): Result; | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
abstract protected function getModelClass(): string; | ||
|
||
abstract protected function getChangeFrequency(): string; | ||
|
||
abstract protected 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
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