Example #1
0
 /**
  * @param PointSet $other
  *
  * @return PointSet
  */
 public function diff(PointSet $other)
 {
     $result = new self();
     $result->addAll($this);
     $result->removeAll($other);
     return $result;
 }
Example #2
0
 /**
  * @param (array|Traversable)[] $sets
  * @return self
  */
 public static function unionAll(array $sets)
 {
     $self = new self();
     foreach ($sets as $set) {
         $self->addAll($set);
     }
     return $self;
 }
 /**
  * Add definition for builder
  *
  * @param array $definition
  * @return $this
  * @throws InvalidStateException
  */
 public function add($definition = array())
 {
     if (!isset($definition['propertyName'])) {
         throw new InvalidStateException("Missing property name!");
     }
     $propertyName = $definition['propertyName'];
     // load default rules
     $builderDefinition = $this->getPropertyRule($propertyName, !(isset($definition['componentType']) && $definition['componentType'] === BuilderDefinition::COMPONENT_TYPE_CONTAINER));
     if (isset($definition['componentType'])) {
         if ($definition['componentType'] === BuilderDefinition::COMPONENT_TYPE_CONTAINER) {
             $container = $this->form->addContainer($propertyName);
             $targetEntity = $this->invokeGetter($propertyName, $this->entity);
             if ($targetEntity === NULL) {
                 $className = $builderDefinition->getTargetEntity();
                 $targetEntity = new $className();
             }
             $isSpecified = isset($definition['settings']) && is_array($definition['settings']) && is_array($definition['settings'][0]);
             /** @var FormBuilder $builder */
             $builder = new self($this->entityFormMapper, $targetEntity, $this->entityManager, $this->dateParser, !$isSpecified, $container);
             if ($isSpecified) {
                 $builder->addAll($definition['settings']);
             }
             // try to map value
             $this->entityFormMapper->mapValueToComponent($targetEntity, $container);
             // end scope
             return $this;
         } else {
             $builderDefinition->setComponentType($definition['componentType']);
         }
     }
     if (isset($definition['settings'])) {
         $settings = $definition['settings'];
         if (isset($settings['required'])) {
             $builderDefinition->setRequired($settings['required']);
         }
         if (isset($settings['placeholder'])) {
             $builderDefinition->setPlaceholder($settings['placeholder']);
         }
         if (isset($settings['validationRules'])) {
             $builderDefinition->setValidationRules($settings['validationRules']);
         }
         if (isset($settings['label'])) {
             $builderDefinition->setLabel($settings['label']);
         }
         if (isset($settings['values']) && is_array($settings['values'])) {
             $builderDefinition->setValues($settings['values']);
         }
         if (isset($settings['value'])) {
             $builderDefinition->setValue($settings['value']);
         }
         if (isset($settings['appendValidationRules']) && is_array($settings['appendValidationRules'])) {
             foreach ($settings['appendValidationRules'] as $row) {
                 $builderDefinition->addValidationRuleRow($row);
             }
         }
     }
     // replace old
     $this->replaceFormControl($builderDefinition);
     return $this;
 }