/** * {@inheritdoc} */ public function addOption(OptionInterface $option) { $optionType = $option->getType(); if (!$this->type && !$optionType) { throw new \UnexpectedValueException('The OptionGroup must have the type set or the Option must have the group type set'); } if (!$optionType) { $option->setType($this->type); } if (!$this->type) { $this->type = $optionType; } if ($this->type != $option->getType()) { throw new \UnexpectedValueException(sprintf('All OptionsNodes in this type must be %s', $this->type)); } $index = $option->getIndex(); $this->options[$index] = $option; }