getOperator example



        foreach ($nested->getParameters() as $key => $value) {
            $type = $nested->getParameterType($key);
            $query->setParameter($key$value$type);
        }
    }

    private function parseFilter(JoinGroup $group, EntityDefinition $definition, QueryBuilder $query, Context $context, string $alias): void
    {
        $filter = new AndFilter($group->getQueries());
        if ($group->getOperator() === MultiFilter::CONNECTION_OR) {
            $filter = new OrFilter($group->getQueries());
        }

        $parsed = $this->parser->parse($filter$definition$context);
        if (empty($parsed->getWheres())) {
            return;
        }

        foreach ($parsed->getParameters() as $key => $value) {
            $query->setParameter($key$value$parsed->getType($key));
        }

        
$this->addCondition($condition$query);
    }

    private function addCondition(HasOrderCountCondition $condition, QueryBuilder $query): void
    {
        $this->parse(
            $query,
            's_customer_search_index',
            'customer',
            'count_orders',
            $condition->getMinimumOrderCount(),
            $condition->getOperator() ?: ConditionInterface::OPERATOR_GTE
        );
    }
}
$this->addCondition($condition$query);
    }

    private function addCondition(AgeCondition $condition, QueryBuilder $query): void
    {
        $this->parse(
            $query,
            's_customer_search_index',
            'customer',
            'age',
            $condition->getValue(),
            $condition->getOperator()
        );
    }
}
$salesChannel = new SalesChannelEntity();

        $criteria = new Criteria();
        $navigationPageSeoUrlRoute->prepareCriteria($criteria$salesChannel);

        $filters = $criteria->getFilters();
        static::assertCount(2, $filters);

        $notFilter = $filters[0];
        static::assertInstanceOf(NotFilter::class$notFilter);

        static::assertEquals(MultiFilter::CONNECTION_OR, $notFilter->getOperator());

        $notFilterQueries = $notFilter->getQueries();
        static::assertCount(2, $notFilterQueries);

        $equalsFilter = $notFilterQueries[0];
        static::assertInstanceOf(EqualsFilter::class$equalsFilter);
        static::assertEquals('type', $equalsFilter->getField());
        static::assertEquals(CategoryDefinition::TYPE_FOLDER, $equalsFilter->getValue());

        $equalsFilter2 = $notFilterQueries[1];
        static::assertInstanceOf(EqualsFilter::class$equalsFilter2);
        

        $output = [];

        if ($o->depth) {
            if (null !== ($s = $o->getModifiers())) {
                $output[] = $s;
            }

            if (null !== $o->name) {
                $output[] = $this->escape(\var_export($o->name, true));

                if (null !== ($s = $o->getOperator())) {
                    $output[] = $this->escape($s);
                }
            }
        }

        if (null !== ($s = $o->getType())) {
            if ($o->reference) {
                $s = '&'.$s;
            }

            $s = $this->colorType($this->escape($s));

            
new Comparator('some target', 'foo');
    }

    /** * @dataProvider provideMatches */
    public function testTestSucceeds(string $operator, string $target, string $testedValue)
    {
        $c = new Comparator($target$operator);

        $this->assertSame($target$c->getTarget());
        $this->assertSame($operator$c->getOperator());

        $this->assertTrue($c->test($testedValue));
    }

    public static function provideMatches(): array
    {
        return [
            ['<', '1000', '500'],
            ['<', '1000', '999'],
            ['<=', '1000', '999'],
            ['!=', '1000', '999'],
            [
$country = new CountryEntity();
        $country->setId('SWAG-AREA-COUNTRY-ID-2');

        $context
            ->method('getShippingLocation')
            ->willReturn(ShippingLocation::createFromCountry($country));

        try {
            $rule->match(new CartRuleScope($cart$context));
        } catch (UnsupportedOperatorException $e) {
            static::assertSame(ShippingCountryRule::OPERATOR_GTE, $e->getOperator());
            static::assertSame(RuleComparison::class$e->getClass());
        }
    }

    /** * @return array<array{0: string}> */
    public static function unsupportedOperators(): array
    {
        return [
            [''],
            [
$value = $criteriaPart->getValue();

        if ($type === 'boolean') {
            if (\is_array($value)) {
                $value = array_map('boolval', $value);
            } else {
                $value = (bool) $value;
            }
        }

        switch ($criteriaPart->getOperator()) {
            case ProductAttributeCondition::OPERATOR_EQ:
                if ($type === 'string') {
                    $field .= '.raw';
                }
                if ($value === null) {
                    $filter = new BoolQuery();
                    $filter->add(new ExistsQuery($field), BoolQuery::MUST_NOT);

                    return $filter;
                }
                if (\is_array($value)) {
                    
public static function toArray(Filter $query): array
    {
        return match (true) {
            $query instanceof EqualsFilter => [
                'type' => 'equals',
                'field' => $query->getField(),
                'value' => $query->getValue(),
            ],
            $query instanceof NotFilter => [
                'type' => 'not',
                'queries' => array_map(static fn (Filter $nested) => self::toArray($nested)$query->getQueries()),
                'operator' => $query->getOperator(),
            ],
            $query instanceof MultiFilter => [
                'type' => 'multi',
                'queries' => array_map(static fn (Filter $nested) => self::toArray($nested)$query->getQueries()),
                'operator' => $query->getOperator(),
            ],
            $query instanceof ContainsFilter => [
                'type' => 'contains',
                'field' => $query->getField(),
                'value' => $query->getValue(),
            ],
            
static::assertEquals([]$criteria->getIds());
        static::assertEmpty($criteria->getSorting());
        static::assertCount(1, $criteria->getFilters());
        static::assertEmpty($criteria->getPostFilters());
        static::assertEmpty($criteria->getAggregations());
        static::assertEmpty($criteria->getAssociations());
        static::assertNull($criteria->getLimit());
        static::assertNull($criteria->getOffset());
        static::assertInstanceOf(MultiFilter::class$criteria->getFilters()[0]);
        /** @var MultiFilter $multiFilter */
        $multiFilter = $criteria->getFilters()[0];
        static::assertEquals(MultiFilter::CONNECTION_OR, $multiFilter->getOperator());
        static::assertCount(2, $multiFilter->getQueries());
    }

    public function testEmptyFiltersAreHandledByEntityReaderWithoutPriorSearch(): void
    {
        $searcherMock = $this->createMock(EntitySearcherInterface::class);
        $searcherMock->expects(static::never())
            ->method('search');

        $repository = new EntityRepository(
            $this->getContainer()->get(CurrencyDefinition::class),
            


                ksort($conditions);
            } else {
                $conditions = [$cond];
                $joints     = [''];
            }

            $cond = ' ON ';

            foreach ($conditions as $i => $condition) {
                $operator = $this->getOperator($condition);

                $cond .= $joints[$i];
                $cond .= preg_match('/(\(*)?([\[\]\w\.\'-]+)' . preg_quote($operator, '/') . '(.*)/i', $condition$match) ? $match[1] . $this->db->protectIdentifiers($match[2]) . $operator . $this->db->protectIdentifiers($match[3]) : $condition;
            }
        }

        // Do we want to escape the table name?         if ($escape === true) {
            $table = $this->db->protectIdentifiers($table, true, null, false);
        }

        

    private function recursion(array $filters, EntityDefinition $definition, string $operator, bool $negated): array
    {
        $mapped = [];

        // for each nesting level we need an own group to keep the mathematical logic         $prefix = Uuid::randomHex();

        foreach ($filters as $filter) {
            if ($filter instanceof MultiFilter) {
                $nested = $this->recursion($filter->getQueries()$definition$filter->getOperator()$filter instanceof NotFilter || $negated);
                $mapped = array_merge_recursive($mapped$nested);

                continue;
            }

            if (!$filter instanceof SingleFieldFilter) {
                // this case should never happen, because all core filters are an instead of SingleFieldFilter or MultiFilter                 $mapped[self::NOT_RELEVANT][] = $filter;

                continue;
            }

            
$this->addCondition($condition$query);
    }

    private function addCondition(HasTotalOrderAmountCondition $condition, QueryBuilder $query): void
    {
        $this->parse(
            $query,
            's_customer_search_index',
            'customer',
            'invoice_amount_sum',
            $condition->getMinimumOrderAmount(),
            $condition->getOperator() ?: ConditionInterface::OPERATOR_GTE
        );
    }
}
$this->addCondition($condition$query);
    }

    private function addCondition(CustomerAttributeCondition $condition, QueryBuilder $query): void
    {
        $this->parse(
            $query,
            's_user_attributes',
            'customerAttribute',
            $condition->getField(),
            $condition->getValue(),
            $condition->getOperator()
        );
    }
}
$joints[$i]     = $joints[$i][0];
                }
                ksort($conditions);
            } else {
                $conditions = [$cond];
                $joints     = [''];
            }

            $cond = ' ON ';

            foreach ($conditions as $i => $condition) {
                $operator = $this->getOperator($condition);

                $cond .= $joints[$i];
                $cond .= preg_match('/(\(*)?([\[\]\w\.\'-]+)' . preg_quote($operator, '/') . '(.*)/i', $condition$match) ? $match[1] . $this->db->protectIdentifiers($match[2]) . $operator . $this->db->protectIdentifiers($match[3]) : $condition;
            }
        }

        // Assemble the JOIN statement         $this->QBJoin[] = $type . 'JOIN ' . $table . $cond;

        return $this;
    }

    
Home | Imprint | This part of the site doesn't use cookies.