Files
kupshop/bundles/KupShop/ContentBundle/Feed/PageConfigurableFeed.php
2025-08-02 16:30:27 +02:00

64 lines
1.6 KiB
PHP

<?php
namespace KupShop\ContentBundle\Feed;
use KupShop\ContentBundle\Feed\Wrapper\PageWrapper;
use KupShop\ContentBundle\Util\MenuUtil;
use KupShop\FeedGeneratorBundle\Feed\ConfigurableFeedTrait;
use KupShop\FeedGeneratorBundle\Feed\IConfigurableFeed;
use KupShop\FeedsBundle\Feed\IFeed;
use KupShop\I18nBundle\Translations\MenuLinksTranslation;
use Query\Operator;
use Query\QueryBuilder;
use Query\Translation;
class PageConfigurableFeed implements IFeed, IConfigurableFeed
{
use \DatabaseCommunication;
use ConfigurableFeedTrait;
/** @var string */
public static $type = 'pageConfigurable';
/** @var string */
public static $alias = 'Stránky';
/** @var string */
public static $objectType = 'page';
/** @var \Query\QueryBuilder */
protected $query;
public function __construct(PageWrapper $pageWrapper)
{
$this->objectWrapper = $pageWrapper;
}
public function getQuery(): QueryBuilder
{
$qb = sqlQueryBuilder()->select('ml.*')
->from('menu_links', 'ml')
->where(Operator::equals(['ml.type' => MenuUtil::TYPE_PAGE]))
->andWhere(Translation::coalesceTranslatedFields(MenuLinksTranslation::class))
->orderBy('ml.parent, ml.list_order');
foreach ($this->specs as $spec) {
$qb->andWhere($spec);
}
$this->query = $qb;
return $qb;
}
public function filterByObjectID($objectID): void
{
$this->specs[] = Operator::equals(['ml.id' => $objectID]);
}
public static function isAllowed(): bool
{
return true;
}
}