Operation::prepareArguments

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Operation
  4. prepareArguments
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/operation.php
  • Класс: BitrixTasksDispatcherOperation
  • Вызов: Operation::prepareArguments
protected function prepareArguments()
{
	$result = array();
	if(!empty($this->parsed['SIGNATURE']['ARGUMENTS']))
	{
		$values = array_change_key_case($this->operation['ARGUMENTS'], CASE_LOWER);

		foreach($this->parsed['SIGNATURE']['ARGUMENTS'] as $argName => $argDesc)
		{
			$typeArray = $argDesc['TYPE'] == static::ARGUMENT_TYPE_ARRAY;

			// check if argument is required, but no value passed for it
			if(!isset($values[$argName]) && $argDesc['REQUIRED'])
			{
				$this->addParseError('Argument "'.$argName.'" is required, but no value passed for '.$this->parsed['FULLPATH']);
				continue;
			}

			// optional argument somewhere in the middle, not passed
			// initialize it with the default value
			if(!isset($values[$argName]) && !$argDesc['REQUIRED'])
			{
				$values[$argName] = $argDesc['DEFAULT_VALUE'];
			}

			if(isset($values[$argName]) && !is_array($values[$argName]) && $typeArray)
			{
                    if((string) $values[$argName] == '')
                    {
                        // it seems an empty array was transferred as an empty string, replace then
                    $values[$argName] = array();
                    }
                    elseif(!is_array($values[$argName]))
                    {
                        $this->addParseError('Argument "'.$argName.'" must be of type array, but given something else for '.$this->parsed['FULLPATH']);
                    }
			}

			// the value is okay
			$result[$argName] = $values[$argName];
		}

		$this->operation['ARGUMENTS'] = $values;
	}

	return $result;
}

Добавить комментарий