- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/message/configuration.php
- Класс: BitrixSenderMessageConfiguration
- Вызов: Configuration::addOption
public function addOption(ConfigurationOption $option, $targetOptionCode = null, $isInsertAfter = true)
{
if ($option->isTemplated() && $this->hasTemplatedOption())
{
throw new ArgumentException('Templated option already exists.');
}
$uniqueTypes = [
ConfigurationOption::TYPE_TEMPLATE_TYPE,
ConfigurationOption::TYPE_TEMPLATE_ID,
];
if (in_array($option->getType(), $uniqueTypes, true) && $this->hasOptionsOfType($option->getType()))
{
throw new ArgumentException('Option with type `' . $option->getType() . '` already exists.');
}
if ($targetOptionCode)
{
$index = array_search($this->getOption($targetOptionCode), $this->options);
if ($isInsertAfter)
{
$index++;
}
$this->options = array_merge(
array_slice($this->options, 0, $index),
[$option],
array_slice($this->options, $index)
);
}
else
{
$this->options[] = $option;
}
}