src/DataDefinition/Palette/Builder/PaletteBuilder.php
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);
                }
            }
        }
    }
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);
                }
            }
        }
    }
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 ) ; } } } }
Add a custom condition to last created property.

@param PropertyConditionInterface $condition The condition to add.
@param string                     $scope     The scope.

@return void

@throws DcGeneralRuntimeException If the the property is missing.
Add a custom condition to last created property .