src/CoreBundle/EventListener/DcGeneral/Table/Attribute/AttributeDeletedListener.php
protected function deleteConditionSettings(PreDeleteModelEvent $event)
    {
        $environment  = $event->getEnvironment();
        $model        = $event->getModel();
        $dataProvider = $environment->getDataProvider('tl_metamodel_dcasetting_condition');

        $conditions = $dataProvider->fetchAll(
            $dataProvider->getEmptyConfig()->setFilter(
                [['operation' => '=', 'property' => 'attr_id', 'value' => $model->getId()]]
            )
        );

        if ($conditions->count() < 1) {
            return;
        }

        $conditionsGeneral            = new \DC_General($dataProvider->getEmptyModel()->getProviderName());
        $conditionsEnvironment        = $conditionsGeneral->getEnvironment();
        $conditionsDataDefinition     = $conditionsEnvironment->getDataDefinition();
        $conditionsPalettesDefinition = $conditionsDataDefinition->getPalettesDefinition();

        /** @var \Iterator $conditionsIterator */
        $conditionsIterator = $conditions->getIterator();
        while ($currentCondition = $conditionsIterator->current()) {
            $conditionPalette    = $conditionsPalettesDefinition->getPaletteByName(
                $currentCondition->getProperty('type')
            );
            $conditionProperties = $conditionPalette->getVisibleProperties(
                $currentCondition
            );

            foreach ($conditionProperties as $conditionProperty) {
                if ($conditionProperty->getName() !== 'attr_id') {
                    continue;
                }

                $dataProvider->delete($currentCondition);
            }

            $conditionsIterator->next();
        }
    }
protected function deleteConditionSettings(PreDeleteModelEvent $event)
    {
        $environment  = $event->getEnvironment();
        $model        = $event->getModel();
        $dataProvider = $environment->getDataProvider('tl_metamodel_dcasetting_condition');

        $conditions = $dataProvider->fetchAll(
            $dataProvider->getEmptyConfig()->setFilter(
                [['operation' => '=', 'property' => 'attr_id', 'value' => $model->getId()]]
            )
        );

        if ($conditions->count() < 1) {
            return;
        }

        $conditionsGeneral            = new \DC_General($dataProvider->getEmptyModel()->getProviderName());
        $conditionsEnvironment        = $conditionsGeneral->getEnvironment();
        $conditionsDataDefinition     = $conditionsEnvironment->getDataDefinition();
        $conditionsPalettesDefinition = $conditionsDataDefinition->getPalettesDefinition();

        /** @var \Iterator $conditionsIterator */
        $conditionsIterator = $conditions->getIterator();
        while ($currentCondition = $conditionsIterator->current()) {
            $conditionPalette    = $conditionsPalettesDefinition->getPaletteByName(
                $currentCondition->getProperty('type')
            );
            $conditionProperties = $conditionPalette->getVisibleProperties(
                $currentCondition
            );

            foreach ($conditionProperties as $conditionProperty) {
                if ($conditionProperty->getName() !== 'attr_id') {
                    continue;
                }

                $dataProvider->delete($currentCondition);
            }

            $conditionsIterator->next();
        }
    }
protected function deleteConditionSettings ( PreDeleteModelEvent $ event ) { $ environment = $ event -> getEnvironment ( ) ; $ model = $ event -> getModel ( ) ; $ dataProvider = $ environment -> getDataProvider ( 'tl_metamodel_dcasetting_condition' ) ; $ conditions = $ dataProvider -> fetchAll ( $ dataProvider -> getEmptyConfig ( ) -> setFilter ( [ [ 'operation' => '=' , 'property' => 'attr_id' , 'value' => $ model -> getId ( ) ] ] ) ) ; if ( $ conditions -> count ( ) < 1 ) { return ; } $ conditionsGeneral = new \ DC_General ( $ dataProvider -> getEmptyModel ( ) -> getProviderName ( ) ) ; $ conditionsEnvironment = $ conditionsGeneral -> getEnvironment ( ) ; $ conditionsDataDefinition = $ conditionsEnvironment -> getDataDefinition ( ) ; $ conditionsPalettesDefinition = $ conditionsDataDefinition -> getPalettesDefinition ( ) ; /** @var \Iterator $conditionsIterator */ $ conditionsIterator = $ conditions -> getIterator ( ) ; while ( $ currentCondition = $ conditionsIterator -> current ( ) ) { $ conditionPalette = $ conditionsPalettesDefinition -> getPaletteByName ( $ currentCondition -> getProperty ( 'type' ) ) ; $ conditionProperties = $ conditionPalette -> getVisibleProperties ( $ currentCondition ) ; foreach ( $ conditionProperties as $ conditionProperty ) { if ( $ conditionProperty -> getName ( ) !== 'attr_id' ) { continue ; } $ dataProvider -> delete ( $ currentCondition ) ; } $ conditionsIterator -> next ( ) ; } }
Delete joint condition setting with attribute.

@param PreDeleteModelEvent $event The event.

@return void
Delete joint condition setting with attribute .