public function testClone()
 {
     $condition = new PropertyConditionChain();
     $condition->addCondition(new PropertyValueCondition('propname', '0'));
     $condition->addCondition(new PropertyValueCondition('propname2', '1'));
     $this->assertCloneMatch($condition);
 }
    $typeCondition = new Property\PropertyValueCondition('type', 'members');
    $filterCondition = new Property\PropertyTrueCondition('filter');
    /** @var Property\PropertyConditionInterface|Property\PropertyConditionChain $visibleCondition */
    if (!$visibleCondition || !$visibleCondition instanceof Property\PropertyConditionChain || $visibleCondition->getConjunction() != Property\PropertyConditionChain::OR_CONJUNCTION) {
        $visibleCondition = new Property\PropertyConditionChain($visibleCondition ? array($visibleCondition) : array(), Property\PropertyConditionChain::OR_CONJUNCTION);
    }
    $visibleCondition->addCondition(new Property\PropertyConditionChain(array($typeCondition, $filterCondition)));
    $membersUseGroupFilterProperty->setVisibleCondition($visibleCondition);
}, function ($legendName, DataDefinition\Palette\Legend $legend, DataDefinition\Palette\Palette $palette, DataDefinition\Definition\PalettesDefinitionInterface $palettesDefinition) {
    $membersUsePropertyFilterProperty = $legend->getProperty('membersUsePropertyFilter');
    $visibleCondition = $membersUsePropertyFilterProperty->getVisibleCondition();
    $typeCondition = new Property\PropertyValueCondition('type', 'members');
    $filterCondition = new Property\PropertyTrueCondition('filter');
    /** @var Property\PropertyConditionInterface|Property\PropertyConditionChain $visibleCondition */
    if (!$visibleCondition || !$visibleCondition instanceof Property\PropertyConditionChain || $visibleCondition->getConjunction() != Property\PropertyConditionChain::AND_CONJUNCTION) {
        $visibleCondition = new Property\PropertyConditionChain($visibleCondition ? array($visibleCondition) : array());
    }
    $visibleCondition->addCondition($typeCondition);
    $visibleCondition->addCondition($filterCondition);
    $membersUsePropertyFilterProperty->setVisibleCondition($visibleCondition);
}), 'expert' => array('disable')));
$TL_DCA['orm_avisota_recipient_source']['metapalettes'] = array_merge($TL_DCA['orm_avisota_recipient_source']['metapalettes'], $metaPalettes);
$metaSubPalettes = array('membersUsePropertyFilter' => array('membersPropertyFilter'), 'membersUseGroupFilter' => array('membersGroupFilter'));
$TL_DCA['orm_avisota_recipient_source']['metasubpalettes'] = array_merge($TL_DCA['orm_avisota_recipient_source']['metasubpalettes'], $metaSubPalettes);
// TODO is this using in future
/*
$GLOBALS['TL_DCA']['orm_avisota_recipient_source']['fields']['membersManageSubscriptionPage'] = array
(
	'label'     => &$GLOBALS['TL_LANG']['orm_avisota_recipient_source']['membersManageSubscriptionPage'],
	'inputType' => 'pageTree',
	'eval'      => array(
Example #3
0
 /**
  * Add a condition to a property.
  *
  * @param PropertyInterface  $property  The property.
  *
  * @param ConditionInterface $condition The condition to add.
  *
  * @return void
  */
 protected function addCondition($property, $condition)
 {
     $currentCondition = $property->getVisibleCondition();
     if (!$currentCondition instanceof ConditionChainInterface || $currentCondition->getConjunction() != ConditionChainInterface::OR_CONJUNCTION) {
         if ($currentCondition === null) {
             $currentCondition = new PropertyConditionChain(array($condition));
         } else {
             $currentCondition = new PropertyConditionChain(array($currentCondition, $condition));
         }
         $currentCondition->setConjunction(ConditionChainInterface::OR_CONJUNCTION);
         $property->setVisibleCondition($currentCondition);
     } else {
         $currentCondition->addCondition($condition);
     }
 }
Example #4
0
 /**
  * Build the data definition palettes.
  *
  * @param string[]                    $propertyNames The property names which shall be masked.
  *
  * @param PalettesDefinitionInterface $palettes      The palette definition.
  *
  * @return void
  */
 public function buildConditions($propertyNames, PalettesDefinitionInterface $palettes)
 {
     foreach ($palettes->getPalettes() as $palette) {
         foreach ($propertyNames as $propertyName => $mask) {
             foreach ($palette->getProperties() as $property) {
                 if ($property->getName() === $propertyName) {
                     // Show the widget when we are editing a select attribute.
                     $condition = new PropertyConditionChain(array(new PropertyConditionChain(array(new PropertyValueCondition('type', 'tags'), new ConditionTableNameIsMetaModel('tag_table', $mask)))), ConditionChainInterface::OR_CONJUNCTION);
                     // If we want to hide the widget for metamodel tables, do so only when editing a select
                     // attribute.
                     if (!$mask) {
                         $condition->addCondition(new NotCondition(new PropertyValueCondition('type', 'tags')));
                     }
                     self::addCondition($property, $condition);
                 }
             }
         }
     }
 }
 /**
  * Parse the sub select palettes into a list of properties and set the corresponding condition.
  *
  * @param array $subSelectPalettesDca The sub select palettes.
  *
  * @return array
  *
  * @throws \InvalidArgumentException
  */
 protected function parseSubSelectPalettes(array $subSelectPalettesDca)
 {
     $subSelectPalettes = array();
     if (is_array($subSelectPalettesDca)) {
         foreach ($subSelectPalettesDca as $selectPropertyName => $valuePropertyNames) {
             $properties = array();
             foreach ($valuePropertyNames as $value => $propertyNames) {
                 if ($value[0] == '!') {
                     $negate = true;
                     $value = substr($value, 1);
                 } else {
                     $negate = false;
                 }
                 $condition = new PropertyValueCondition($selectPropertyName, $value);
                 if ($negate) {
                     $condition = new NotCondition($condition);
                 }
                 $and = new PropertyConditionChain();
                 $and->addCondition($condition);
                 $and->addCondition(new PropertyVisibleCondition($selectPropertyName));
                 foreach ($propertyNames as $key => $propertyName) {
                     // Check if it is a legend information, if so add it to that one - use the empty legend name
                     // otherwise.
                     if (is_array($propertyName)) {
                         foreach ($propertyName as $propName) {
                             $property = new Property($propName);
                             $property->setVisibleCondition(clone $and);
                             $properties[$key][] = $property;
                         }
                     } else {
                         $property = new Property($propertyName);
                         $property->setVisibleCondition(clone $and);
                         $properties[''][] = $property;
                     }
                 }
             }
             if (count($properties)) {
                 $subSelectPalettes[$selectPropertyName] = $properties;
             }
         }
     }
     return $subSelectPalettes;
 }