/**
  * {@inheritdoc}
  */
 public function setPosition($position)
 {
     if ($this->locked) {
         throw new BadMethodCallException('The config builder cannot be modified anymore.');
     }
     if (is_string($position) && $position !== 'first' && $position !== 'last') {
         throw OrderedConfigurationException::createInvalidStringPosition($this->getName(), $position);
     }
     if (is_array($position) && !isset($position['before']) && !isset($position['after'])) {
         throw OrderedConfigurationException::createInvalidArrayPosition($this->getName(), $position);
     }
     $this->position = $position;
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Detects symmetric before/after differed.
  *
  * @param string $name     The form name.
  * @param string $differed The differed form name.
  * @param string $position The position (before|after).
  *
  * @throws \Ivory\OrderedForm\Exception\OrderedConfigurationException If there is a symetric before/after differed.
  */
 protected function detectedSymmetricDiffered($name, $differed, $position)
 {
     $reversePosition = $position === 'before' ? 'after' : 'before';
     if (isset($this->differed[$reversePosition][$name])) {
         foreach ($this->differed[$reversePosition][$name] as $diff) {
             if ($diff->getName() === $differed) {
                 throw OrderedConfigurationException::createSymetricDiffered($name, $differed);
             }
         }
     }
 }