Add a custom condition to last created palette.

@param PaletteConditionInterface $condition The condition to add.

@return void

@throws DcGeneralRuntimeException If the palette is missing.
178618
protected function addPaletteCondition(PaletteConditionInterface $condition)
    {
        if (!$this->palette) {
            throw new DcGeneralRuntimeException('Palette is missing, please create a palette first');
        }

        $event = new AddConditionEvent($condition, $this->palette, $this);
        $this->dispatchEvent($event);
        $condition = $event->getCondition();

        $previousCondition = $this->palette->getCondition();

        if (!$previousCondition) {
            $this->palette->setCondition($condition);
        } elseif ($previousCondition instanceof PropertyConditionChain) {
            $previousCondition->addCondition($condition);
        } else {
            $chain = $this->paletteConditionChainClass->newInstance();
            $chain->addCondition($previousCondition);
            $chain->addCondition($condition);
            $this->palette->setCondition($chain);
        }
    }
411835
public function mapCondition(PersistenceCondition $condition): Condition
    {
        try {
            $conditionType = $this->conditionTypeRegistry->getConditionType(
                $condition->type
            );
        } catch (ConditionTypeException $e) {
            $conditionType = new NullConditionType();
        }

        $conditionData = [
            'id' => $condition->id,
            'status' => $condition->status,
            'ruleId' => $condition->ruleId,
            'conditionType' => $conditionType,
            'value' => $condition->value,
        ];

        return Condition::fromArray($conditionData);
    }
741494
public function prependIf($condition, string $prepend)
    {
        if ($this->resolveCondition($condition)) {
            return $this->prepend($prepend);
        }

        return $this;
    }
590525
public function addCondition( $condition )
	{
		if( is_array( $condition ) )
			return $this->addConditions( $condition );
		if( in_array( $condition, $this->conditions ) )
			return FALSE;
		$this->conditions[] = $condition;
		return TRUE;
	}
954210
public void addCondition( Condition condition, String transitionName ){
        conditions.add( Pair.of( condition, transitionName ) );
    }
714254
protected function addPropertyCondition(PropertyConditionInterface $condition, $scope = self::VISIBLE)
    {
        if (!$this->property) {
            throw new DcGeneralRuntimeException('Property is missing, please create a property first');
        }

        $properties = \is_object($this->property) ? [$this->property] : $this->property;

        foreach ($properties as $property) {
            /** @var PropertyInterface $property */
            $event = new AddConditionEvent($condition, $property, $this);
            $this->dispatchEvent($event);
            $condition = $event->getCondition();

            $previousCondition = self::EDITABLE === $scope
                ? $property->getEditableCondition()
                : $property->getVisibleCondition();

            if (!$previousCondition) {
                if (self::EDITABLE === $scope) {
                    $property->setEditableCondition($condition);
                } else {
                    $property->setVisibleCondition($condition);
                }
            } elseif ($previousCondition instanceof PropertyConditionChain) {
                $previousCondition->addCondition($condition);
            } else {
                $chain = $this->propertyConditionChainClass->newInstance();
                $chain->addCondition($previousCondition);
                $chain->addCondition($condition);

                if (self::EDITABLE === $scope) {
                    $property->setEditableCondition($chain);
                } else {
                    $property->setVisibleCondition($chain);
                }
            }
        }
    }
612789
public function addCondition(Condition $condition): Condition
    {
        $query = $this->connection->createQueryBuilder()
            ->insert('ngbm_rule_condition')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'rule_id' => ':rule_id',
                    'type' => ':type',
                    'value' => ':value',
                ]
            )
            ->setValue(
                'id',
                $condition->id !== null ?
                    (int) $condition->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
            )
            ->setParameter('status', $condition->status, Type::INTEGER)
            ->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
            ->setParameter('type', $condition->type, Type::STRING)
            ->setParameter('value', json_encode($condition->value), Type::STRING);

        $query->execute();

        $condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');

        return $condition;
    }
1079909
public function setCondition($condition)
    {
        if ($condition === null) {
            $this->condition = $condition;
            return $this;
        }

        if (!is_string($condition)) {
            throw new InvalidArgumentException(
                'Custom expression must be a string.'
            );
        }

        $condition = trim($condition);
        if ($condition === '') {
            $condition = null;
        }

        $this->condition = $condition;
        return $this;
    }
636238
private function _prepareCondition(ConditionInterface $condition = null)
	{
		$this->condition = $this->expressionBuilderFactory->create($condition)->build();
	}
1354127
public function addProperty($property)
    {
        if (!($property instanceof PropertyInterface)) {
            throw new DcGeneralInvalidArgumentException('Passed value is not an instance of PropertyInterface.');
        }

        $name = $property->getName();

        if ($this->hasProperty($name)) {
            throw new DcGeneralInvalidArgumentException('Property ' . $name . ' is already registered.');
        }

        $this->properties[$name] = $property;

        return $this;
    }
867215
public function finishPalette(&$palette = null)
    {
        if (!$this->palette) {
            throw new DcGeneralRuntimeException('Palette is missing, please create a palette first');
        }

        if ($this->legend) {
            $this->finishLegend();
        }
        if ($this->condition) {
            $this->finishCondition();
        }

        $event = new FinishPaletteEvent($this->palette, $this);
        $this->dispatchEvent($event);
        $palette = $event->getPalette();

        if ($this->paletteCollection) {
            $this->paletteCollection->addPalette($palette);
        }

        $this->palette = null;

        return $this;
    }
550807
public function setConditions( MW_Common_Criteria_Expression_Interface $conditions )
	{
		if( $conditions instanceof MW_Common_Criteria_Expression_Sort_Interface ) {
			throw new MW_Common_Exception( 'Sortation objects are not allowed' );
		}

		$this->_conditions = $conditions;
		return $this;
	}
308400
public void fillAllConditions(Condition condition) {
        if (_valueColumns != null) {
            final Condition[] conditions = new Condition[_valueColumns.length];
            Arrays.fill(conditions, condition);
            _conditions = conditions;
        }
    }
121524
protected function _evaluateCondition($condition, Event $event)
    {
        if (!isset($this->_options[$condition])) {
            return $condition !== 'unless';
        }
        if (!is_callable($this->_options[$condition])) {
            throw new RuntimeException(self::class . ' the `' . $condition . '` condition is not a callable!');
        }

        return $this->_options[$condition]($event);
    }
989415
public function addCondition($condition)
    {
        if (!$this->conditions->contains($condition)) {
            $this->conditions[] = $condition;
        }

        return $this;
    }
594620
private function prepareCondition($condition)
    {
        if (!is_array($condition)) {
            $condition = ['in' => [$condition]];
        }

        $conditionKeys = array_keys($condition);

        if (is_integer(current($conditionKeys))) {
            $condition = ['in' => $condition];
        }

        foreach ($condition as $key => $value) {
            if (!isset($this->mappedConditions[$key]) && !in_array($key, $this->rangeConditions)) {
                throw new \LogicException("Condition {$key} is not supported.");
            }

            if (isset($this->mappedConditions[$key])) {
                $condition[$this->mappedConditions[$key]] = $value;
                unset($condition[$key]);
            }

            if (in_array($key, $this->negativeConditions)) {
                $condition['negative'] = true;
            }
        }

        return $condition;
    }
491010
public function add($condition, array $params = [])
    {
        $this->conditions[] = $condition;
        $this->bind($params);
        return $this;
    }