getBaseQuery example


    public function getName(): string
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null): array
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['id'])
            ->setParameter(':shop', $context->getShopId())
            ->orderBy('id');

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['cat.id', 'cat.blog'])
            ->orderBy('ISNULL(cat.path)', 'DESC')
            ->addOrderBy('id', 'ASC')
            ->setParameter(':shop', $context->getShopId())
            ->andWhere('cat.shops IS NULL OR cat.shops LIKE :shopLike')
            ->setParameter(':shopLike', '%|' . $context->getShopId() . '|%');

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['DISTINCT details.articleID'])
            ->andWhere('details.kind = 1')
            ->orderBy('details.articleID', 'ASC')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['emo.id', 'emo.is_landingpage', '(cat.path IS NULL) AS isIndex'])
            ->orderBy('emo.id')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        

  public function __construct(Connection $connection) {
    $this->connection = $connection;
  }

  /** * {@inheritdoc} */
  public function preloadPathAlias($preloaded$langcode) {
    $select = $this->getBaseQuery()
      ->fields('base_table', ['path', 'alias']);

    if (!empty($preloaded)) {
      $conditions = $this->connection->condition('OR');
      foreach ($preloaded as $preloaded_item) {
        $conditions->condition('base_table.path', $this->connection->escapeLike($preloaded_item), 'LIKE');
      }
      $select->condition($conditions);
    }

    $this->addLanguageFallback($select$langcode);

    

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['blog.id AS blogID', 'cat.id AS catID'])
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        if (!\count($result)) {
            
private readonly EntityScoreQueryBuilder $scoreBuilder,
        private readonly JoinGroupBuilder $joinGrouper,
        private readonly CriteriaPartResolver $criteriaPartResolver
    ) {
    }

    /** * @param list<string> $paths */
    public function build(QueryBuilder $query, EntityDefinition $definition, Criteria $criteria, Context $context, array $paths = []): QueryBuilder
    {
        $query = $this->helper->getBaseQuery($query$definition$context);

        if ($definition->isInheritanceAware() && $context->considerInheritance()) {
            $parent = $definition->getFields()->get('parent');

            if ($parent) {
                $this->helper->resolveField($parent$definition$definition->getEntityName()$query$context);
            }
        }

        if ($criteria->getTerm()) {
            $pattern = $this->interpreter->interpret((string) $criteria->getTerm());
            
public function setWorkspacesManager(WorkspaceManagerInterface $workspace_manager) {
    $this->workspaceManager = $workspace_manager;
    return $this;
  }

  /** * {@inheritdoc} */
  protected function getBaseQuery() {
    // Don't alter any queries if we're not in a workspace context.     if (!$this->workspaceManager->hasActiveWorkspace()) {
      return parent::getBaseQuery();
    }

    $active_workspace = $this->workspaceManager->getActiveWorkspace();

    $query = $this->connection->select('path_alias', 'base_table_2');
    $wa_join = $query->leftJoin('workspace_association', NULL, "[%alias].[target_entity_type_id] = 'path_alias' AND [%alias].[target_entity_id] = [base_table_2].[id] AND [%alias].[workspace] = :active_workspace_id", [
      ':active_workspace_id' => $active_workspace->id(),
    ]);
    $query->innerJoin('path_alias_revision', 'base_table', "[%alias].[revision_id] = COALESCE([$wa_join].[target_entity_revision_id], [base_table_2].[revision_id])");

    return $query;
  }

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['details.articleID', 'cat.id AS catId'])
            ->andWhere('details.kind = 1')
            ->addOrderBy('details.articleID', 'ASC')
            ->addOrderBy('cat.id', 'ASC')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['id', 'link'])
            ->setParameter(':shop', $context->getShopId())
            ->orderBy('id');

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['details.articleID', 'details.ordernumber', 'details.kind', "GROUP_CONCAT( 'group[', opt.group_id, ']=', opt_rel.option_id ORDER BY opt.group_id ASC SEPARATOR '&') AS 'link'"])
            ->where(sprintf('article.id IN (%s)', $this->prepareSubQuery()->getSQL()))
            ->groupBy('details.ordernumber')
            ->orderBy('details.ordernumber', 'ASC')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['DISTINCT details.articleID', 'details.ordernumber'])
            ->orderBy('details.articleID', 'ASC')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        

    public function getName()
    {
        return self::NAME;
    }

    /** * {@inheritdoc} */
    public function getUrls(Context $context$limit = null, $offset = null)
    {
        $qb = $this->getBaseQuery()
            ->addSelect(['id'])
            ->orderBy('id');

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $result = $qb->execute()->fetchAll();

        if (!\count($result)) {
            
Home | Imprint | This part of the site doesn't use cookies.