/**
  * Assert that the property information is matching.
  *
  * @param Property    $property               The property info to check.
  *
  * @param string      $name                   The property name.
  *
  * @param null|string $visibleConditionClass  The class for the visible condition.
  *
  * @param null|string $editableConditionClass The class for the editable condition.
  *
  * @return void
  */
 protected function assertProperty($property, $name, $visibleConditionClass = null, $editableConditionClass = null)
 {
     $this->assertEquals($name, $property->getName(), 'property name mismatch');
     if ($visibleConditionClass === null) {
         $this->assertNull($property->getVisibleCondition());
     } else {
         $this->assertInstanceOf($visibleConditionClass, $property->getVisibleCondition(), $property->getName() . ' getVisibleCondition()');
     }
     if ($editableConditionClass === null) {
         $this->assertNull($property->getEditableCondition());
     } else {
         $this->assertInstanceOf($editableConditionClass, $property->getEditableCondition(), $property->getName() . ' getVisibleCondition()');
     }
 }
 /**
  * Parse the list of sub palette fields into an array of properties.
  *
  * @param string $subPaletteSelector The selector in use.
  *
  * @param string $childFields        List of the properties for the sub palette.
  *
  * @param array  $selectorFieldNames List of the selector properties [optional].
  *
  * @return PropertyInterface[]
  */
 public function parseSubpalette($subPaletteSelector, $childFields, array $selectorFieldNames = array())
 {
     $childFields = explode(',', $childFields);
     $childFields = array_map('trim', $childFields);
     $condition = $this->createSubpaletteCondition($subPaletteSelector, $selectorFieldNames);
     $properties = array();
     foreach ($childFields as $childField) {
         $property = new Property($childField);
         $property->setVisibleCondition(clone $condition);
         $properties[] = $property;
     }
     return $properties;
 }
 /**
  * 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;
 }