...Человеческий поиск в разработке...
- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/task/dependence.php
- Класс: Bitrix\Tasks\Task\does
- Вызов: does::createLink
static function createLink($id, $parentId, $behaviour = array()) { // bless the php7 // was: ($id, $parentId, $type = self::LINK_TYPE_FINISH_START, array $behaviour = array()) $type = self::LINK_TYPE_FINISH_START; if(func_num_args() > 2) // the third argument may be $type or $behaviour { $arg3 = func_get_arg(2); if(is_array($arg3)) { $behaviour = $arg3; } else { $type = $arg3; if(func_num_args() > 3) { $behaviour = func_get_arg(3); } } } else { $behaviour = array(); } if(array_key_exists('LINK_TYPE', $behaviour)) { $type = $behaviour['LINK_TYPE']; } $id = Assert::expectIntegerPositive($id, '$id'); $parentId = Assert::expectIntegerPositive($parentId, '$parentId'); $type = Assert::expectEnumerationMember($type, array( self::LINK_TYPE_START_START, self::LINK_TYPE_START_FINISH, self::LINK_TYPE_FINISH_START, self::LINK_TYPE_FINISH_FINISH ), '$type'); $exceptionInfo = array( 'AUX' => array( 'MESSAGE' => array( 'FROM_TASK_ID' => $parentId, 'TASK_ID' => $id, 'LINK_TYPE' => $type ) ) ); $result = new AddResult(); if(is_array($behaviour['TASK_DATA']) && !empty($behaviour['TASK_DATA'])) { $toTask = $behaviour['TASK_DATA']; } else { $toTask = TaskTable::getById($id)->fetch(); } if(empty($toTask)) { throw new ActionFailedException('Task not found', $exceptionInfo); } if(is_array($behaviour['PARENT_TASK_DATA']) && !empty($behaviour['PARENT_TASK_DATA'])) { $fromTask = $behaviour['PARENT_TASK_DATA']; } else { $fromTask = TaskTable::getById($parentId)->fetch(); } if(empty($fromTask)) { throw new ActionFailedException('Parent task not found', $exceptionInfo); } if((string) $toTask['CREATED_DATE'] == '') { $result->addError(new Error(Loc::getMessage('DEPENDENCE_ENTITY_CANT_ADD_LINK_CREATED_DATE_NOT_SET'))); } if((string) $toTask['END_DATE_PLAN'] == '') { $result->addError(new Error(Loc::getMessage('DEPENDENCE_ENTITY_CANT_ADD_LINK_END_DATE_PLAN_NOT_SET'))); } if((string) $fromTask['CREATED_DATE'] == '') { $result->addError(new Error(Loc::getMessage('DEPENDENCE_ENTITY_CANT_ADD_LINK_CREATED_DATE_NOT_SET_PARENT_TASK'))); } if((string) $fromTask['END_DATE_PLAN'] == '') { $result->addError(new Error(Loc::getMessage('DEPENDENCE_ENTITY_CANT_ADD_LINK_END_DATE_PLAN_NOT_SET_PARENT_TASK'))); } if(!$result->isSuccess()) { return $result; } else { $linkData = array('TYPE' => $type); if(array_key_exists('CREATOR_ID', $behaviour) && intval($behaviour['CREATOR_ID'])) { $linkData['CREATOR_ID'] = $behaviour['CREATOR_ID']; } return parent::createLink($id, $parentId, array('LINK_DATA' => $linkData)); } }