Пример #1
0
 /**
  * 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;
 }