@param $taskId

@return array
167841
public function getLogsForTaskId($taskId): array
    {
        $logEntries = [];

        foreach (ImageResizer::$plugin->logs->getLogEntries() as $entry) {
            if ($entry->taskId == $taskId) {
                $logEntries[] = $entry;
            }
        }

        return $logEntries;
    }
1182155
public function getUserCapabilities(string $userId): array
    {
        if (empty($this->userCapabilities)) {
            $this->userCapabilities = Utils::fetchUserCapabilities($userId);
        }

        return $this->userCapabilities;
    }
428381
public function read($reportID) {
        $result = $this->api->request(
            'cmdb.reports',
            [
                'id' => $reportID
            ]
        );

        if (!is_array($result)) {
            return [];
        }

        return $result;
    }
611489
public function exists(string $taskID, string $listID = ''): bool
    {
        $list = $this->getListData($listID);
        if (isset($list[$taskID])) {
            $app = App::get();
            return $app->data->exists($this->getTaskDataKey($taskID, $listID));
        }
        return false;
    }
232085
public function addProjectToTask($taskId, $projectId = null)
    {
        $data = [
            'project' => $projectId ?: $this->defaultProjectId
        ];

        return $this->curl->post("tasks/{$taskId}/addProject", ['data' => $data]);
    }
830423
public function getTasks()
    {
        $tasks = [];
        for ($i = 0, $size = count($this->children); $i < $size; $i++) {
            $tsk = $this->children[$i];
            if ($tsk instanceof Task) {
                // note: we're copying objects here!
                $tasks[] = clone $tsk;
            }
        }

        return $tasks;
    }
463761
public function getKnownBranches($projectId)
    {
        $query = 'SELECT DISTINCT branch from build WHERE project_id = :pid';
        $stmt = Database::getConnection('read')->prepare($query);
        $stmt->bindValue(':pid', $projectId);

        if ($stmt->execute()) {
            $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $map = function ($item) {
                return $item['branch'];
            };
            $rtn = array_map($map, $res);

            return $rtn;
        } else {
            return array();
        }
    }
567130
public function getRaw($fileId = null)
    {
        // does nothing with the text
        $lamdaFunction = function($text){ 
            return [$text];
        };        
        return $this->getWords($fileId, new LambdaTokenizer($lamdaFunction));        
    }
742998
public function getExecTasks(): array
    {
        $data = [];
        $runTimeTableTasks = $this->getRunTimeTable()->table;
        if (\count($runTimeTableTasks) <= 0) {
            return $data;
        }

        $min = date('YmdHi');

        foreach ($runTimeTableTasks as $key => $value) {
            if ($value['minute'] == $min) {
                if (time() == $value['sec'] && $value['runStatus'] == self::NORMAL) {
                    $data[] = [
                        'key'        => $key,
                        'taskClass'  => $value['taskClass'],
                        'taskMethod' => $value['taskMethod'],
                    ];
                }
            }
        }

        foreach ($data as $item) {
            $this->startTask($item['key']);
        }

        return $data;
    }
1284180
public function getByTask($task_id, array $params = [])
    {
        $task_id = (int) $task_id;
        if ($task_id <= 0) {
            throw new Exception('Invalid param task_id');
        }
        return $this->rest->get("todo_items/$task_id/$this->action", $params);
    }
528934
public function getUserTasks($options=array()){

        $data = array();
        

        $data = array_merge($data, $options);

        return $this->request($this->taskQueryUrl, $data);
    }
982755
public function restart($taskId) {
		if (!$this->stop($taskId)) {
			return false;
		}

		$task = array(
			'id' => null,
			'stderr' => '',
			'stdout' => '',
			'status' => TaskType::UNSTARTED,
			'code' => '',
			'code_string' => '',
			'started' => '',
			'stopped' => '',
			'server_id' => 0,
				) + $this->read(null, $taskId)[$this->alias];
		$this->create();		
		$success = (bool)$this->saveAssociated(array(
					$this->alias => $task,
					$this->DependsOnTask->alias => array($taskId)
		));
		return $success ? $this->id : $success;
	}
20585
public function getStats(string $listID = ''): array
    {
        $result = [];
        $result['upcomingTasksCount'] = 0;
        $result['upcomingTasks'] = [];
        $result['nextTaskStartTime'] = null;

        $currentTime = time();
        $list = $this->getListData($listID);
        foreach ($list as $taskID => $taskListData) {
            $result['upcomingTasksCount'] ++;
            if ($taskListData[0] === 1) { // version check
                $startTime = $taskListData[1];
                $result['upcomingTasks'][] = ['id' => $taskID, 'startTime' => $startTime];
                $tempStartTime = $startTime === null ? $currentTime : $startTime;
                if ($result['nextTaskStartTime'] === null || $result['nextTaskStartTime'] > $tempStartTime) {
                    $result['nextTaskStartTime'] = $tempStartTime;
                }
            }
        }

        return $result;
    }
108964
public function view($taskId) {
		$task = $this->TaskClient->find('first', array(
			'conditions' => array(
				'id' => $taskId
			),
			'contain' => array(
				'DependsOnTask' => array(
					'id',
					'status'
				)
			)
		));

		if (!$task) {
			throw new NotFoundException("Task id=$taskId not found!");
		}

		$commandList = array($task['TaskClient']['command'] => $task['TaskClient']['command']);
		$approximateRuntimes = array_map(function($command) {
			return $this->TaskProfiler->approximateRuntime($command);
		}, $commandList);
		$this->set('task', $task['TaskClient']);
		$this->set('dependentTasks', $task['DependsOnTask']);
		$statistics = $this->TaskStatistics->find('all', array(
			'conditions' => array(
				'task_id' => $taskId
			),
			'group' => array('CEIL(memory)', 'CEIL(cpu)', 'status'),
			'order' => array(
				'created' => 'asc'
			)
		));
		$this->set('statistics', Hash::extract($statistics, '{n}.{s}'));
		$this->set('approximateRuntimes', $approximateRuntimes);
	}
14523
private function getTaskConfigurationParameters($taskClass)
    {
        $parameters = array();

        $reflectionClass = new ReflectionClass($taskClass);
        $reflectionConstructorMethod = $reflectionClass->getConstructor();
        if ($reflectionConstructorMethod instanceof ReflectionMethod) {
            foreach ($reflectionConstructorMethod->getParameters() as $reflectionParameter) {
                if ($reflectionParameter instanceof ReflectionParameter && $reflectionParameter->isDefaultValueAvailable() === false) {
                    $parameterValue = '';
                    if ($reflectionParameter->isArray()) {
                        $parameterValue = array();
                    }

                    $parameters[$reflectionParameter->getName()] = $parameterValue;
                }
            }
        }

        return $parameters;
    }
1032647
public function getTask(int $taskId)
    {
        if ( ! $this->validateId($taskId)) {
            return false;
        }

        $result = $this->get('tasks/' . $taskId);

        $status = $result->getStatusCode();
        if (200 === $status) {
            return json_decode($result->getBody()->getContents());
        }

        return false;
    }
133087
public function build(array &$errors = null):array {
		$updatedTasks = [];
		foreach($this->taskList as $pathMatch => $task) {
			if($task->build($errors)) {
				$updatedTasks []= $task;
			}
		}

		return $updatedTasks;
	}