Create a tree from the given taskname

@param string $taskName
@param string $postfix
@param bool $isLast

@return void
180271
private function createTreeFromTaskName($taskName, $postfix = '', $isLast = false)
    {
        $task = $this->tasks->get($taskName);

        if ($task->getBefore()) {
            $beforePostfix = sprintf(' [before:%s]', $task->getName());

            foreach ($task->getBefore() as $beforeTask) {
                $this->createTreeFromTaskName($beforeTask, $beforePostfix);
            }
        }

        if ($task instanceof GroupTask) {
            $isLast = $isLast && empty($task->getAfter());

            $this->addTaskToTree($task->getName() . $postfix, $isLast);

            if (!$isLast) {
                $this->openGroupDepths[] = $this->depth;
            }

            $this->depth++;

            $taskGroup = $task->getGroup();
            foreach ($taskGroup as $subtask) {
                $isLastSubtask = $subtask === end($taskGroup);
                $this->createTreeFromTaskName($subtask, '', $isLastSubtask);
            }

            if (!$isLast) {
                array_pop($this->openGroupDepths);
            }

            $this->depth--;
        } else {
            $this->addTaskToTree($task->getName() . $postfix, $isLast);
        }

        if ($task->getAfter()) {
            $afterPostfix = sprintf(' [after:%s]', $task->getName());

            foreach ($task->getAfter() as $afterTask) {
                $this->createTreeFromTaskName($afterTask, $afterPostfix);
            }
        }
    }
1358441
public function insert(Tasks_TaskList $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('insert', array($params), "Tasks_TaskList");
  }
717055
protected function loadTask($task_name) {
		try {
			if (file_exists($this->root_path . $task_name .'.php')) {
				$task = include $this->root_path . $task_name .'.php';
				if($task instanceof AbstractTask) {
				    $task->setProvider($this);
					return $task;
				}
			}
		}
		catch(\Exception $ex) { }
		
		return null;
	}
35096
public static function deliverByProcess(
        string $taskName,
        string $methodName,
        array $params = [],
        int $timeout = 3,
        int $workerId = 0,
        string $type = self::TYPE_ASYNC
    ): bool {
        /* @var PipeMessageInterface $pipeMessage */
        $pipeMessage = bean(PipeMessage::class);
        $message = $pipeMessage->pack(PipeMessage::MESSAGE_TYPE_TASK, [
            'name' => $taskName,
            'method' => $methodName,
            'params' => $params,
            'timeout' => $timeout,
            'type' => $type,
        ]);
        return App::$server->getServer()->sendMessage($message, $workerId);
    }
769766
public function createAction(NodeInterface $postNode, NodeTemplate $newComment)
    {
        # Workaround until we can validate node templates properly:
        if (strlen($newComment->getProperty('author')) < 2) {
            $this->throwStatus(400, 'Your comment was NOT created - please specify your name.');
        }

        if (filter_var($newComment->getProperty('emailAddress'), FILTER_VALIDATE_EMAIL) === false) {
            $this->throwStatus(400, 'Your comment was NOT created - you must specify a valid email address.');
        }

        if (strlen($newComment->getProperty('text')) < 5) {
            $this->throwStatus(400, 'Your comment was NOT created - it was too short.');
        }

        $newComment->setProperty('text', filter_var($newComment->getProperty('text'), FILTER_SANITIZE_STRIPPED));
        $newComment->setProperty('author', filter_var($newComment->getProperty('author'), FILTER_SANITIZE_STRIPPED));
        $newComment->setProperty('emailAddress', filter_var($newComment->getProperty('emailAddress'), FILTER_SANITIZE_STRIPPED));

        $commentNode = $postNode->getNode('comments')->createNodeFromTemplate($newComment, uniqid('comment-'));
        $commentNode->setProperty('spam', false);
        $commentNode->setProperty('datePublished', new \DateTime());

        if ($this->akismetService->isCommentSpam('', $commentNode->getProperty('text'), 'comment', $commentNode->getProperty('author'), $commentNode->getProperty('emailAddress'))) {
            $commentNode->setProperty('spam', true);
        }

        $this->emitCommentCreated($commentNode, $postNode);
        $this->response->setStatus(201);

        return 'Thank you for your comment!';
    }
921322
public function serialize(Task $task)
    {
        $assignedUser = $this->userManager->find($task->getAssignedUserId());
        $createUser = $this->userManager->find($task->getCreateUserId());

        $type = $this->types->get($task->getType());

        $transitions = [];
        foreach ($task->getTransitions() as $transition) {
            $transitionUser = $this->userManager->find($transition->getCreateUserId());
            $createdAt = $transition->getCreatedAt()->format('Y-m-d H:i:s');
            $transitions[$createdAt.'_'.$transition->getId()] = [
                'id' => $transition->getId(),
                'name' => $transition->getName(),
                'new_state' => $transition->getNewState(),
                'old_state' => $transition->getOldState(),
                'created_at' => $createdAt,
                'create_user' => $transitionUser->getDisplayName(),
            ];
        }
        ksort($transitions);
        $transitions = array_values($transitions);

        $comments = [];
        foreach ($task->getComments() as $comment) {
            $commentUser = $this->userManager->find($comment->getCreateUserId());
            $createdAt = $comment->getCreatedAt()->format('Y-m-d H:i:s');
            $comments[$createdAt.'_'.$comment->getId()] = [
                'id' => $comment->getId(),
                'current_state' => $comment->getCurrentState(),
                'comment' => $comment->getComment(),
                'created_at' => $createdAt,
                'create_user' => $commentUser->getDisplayName(),
            ];
        }
        ksort($comments);
        $comments = array_values($comments);

        $taskData = [
            'id' => $task->getId(),
            'type' => $task->getType(),
            'generic' => $task->getType() === 'generic',
            'name' => $type->getName(),
            'summary' => $task->getSummary(),
            'description' => $task->getDescription(),
            'component' => $type->getComponent(),
            'link' => $type->getLink($task),
            'assigned_user_id' => $task->getAssignedUserId(),
            'assigned_user' => $assignedUser->getDisplayName(),
            'status' => $task->getFiniteState(),
            'create_user' => $createUser->getDisplayName(),
            'create_user_id' => $task->getCreateUserId(),
            'created_at' => $task->getCreatedAt()->format('Y-m-d H:i:s'),
            'transitions' => $transitions,
            'comments' => $comments,
            'states' => $this->taskManager->getTransitions($task),
        ];

        return $taskData;
    }
160909
public function setTaskOptions($taskName, $options)
    {
        $baseTask = $taskName;
        if (isset($this->tasks['defined'][$taskName]) && is_array($this->tasks['defined'][$taskName])) {
            $definedTask = $this->tasks['defined'][$taskName];
            $baseTask = $definedTask['task'];
            if (is_array($definedTask['options'])) {
                $options = array_merge_recursive($definedTask['options'], $options);
            }
        }
        $this->defineTask($taskName, $baseTask, $options);

        return $this;
    }
559399
protected function _receive_post($task = false, $primary = false)
    {
        if (!$this->table_name && !$this->query)
            $this->table_name = $this->_humanize(mb_substr($this->table, mb_strlen($this->prefix)));
        if ($task)
        {
            switch ($task)
            {
                case 'create':
                    $this->task = $task;
                    $this->before = $task;
                    return;
                    break;
                case 'edit':
                case 'view':
                    if ($primary !== false)
                    {
                        $this->task = $task;
                        $this->before = $task;
                        $this->primary_val = $primary;
                        return;
                    }
                    break;
                case 'list':
                    $this->task = $task;
                    return;
                    break;
            }
        }
        else
        {
            $this->task = $this->_post('task', 'list');
        }
        if ($this->is_get)
        {
            $this->task = $this->_get('task');
            $this->primary_val = $this->_get('primary');
        }
        else
        {
            $this->order_column = $this->_post('orderby', false, 'key');
            $this->order_direct = $this->_post('order') == 'desc' ? 'desc' : 'asc';
            if ($this->order_column)
            {
                if (!$this->query)
                    $this->order_column = key($this->_parse_field_names($this->order_column, 'receive_post', false, false));
                if (isset($this->order_by[$this->order_column]))
                    unset($this->order_by[$this->order_column]);
                $this->order_by = array_merge(array($this->order_column => $this->order_direct), $this->order_by);
            }

            $this->search = $this->_post('search', $this->search, 'int');
            if ($this->search)
            {
                $this->column = $this->_post('column', false, 'key');
                $this->phrase = $this->_post('phrase');
                $this->range = $this->_post('range', '');
            }
            $this->start = $this->_post('start', 0, 'int');
            $this->limit = $this->_post('limit', ($this->limit ? $this->limit : Fruit_config::$limit));
            $this->after = $this->_post('after');
            $this->primary_val = $this->_post('primary');

        }
    }
338697
private function _getCreateTaskTemplateContext(TaskTemplate $taskTemplate)
    {
        $result = new HttpCallContext();
        $result->setMethod(Resources::HTTP_POST);
        $result->setHeaders($this->_batchHeaders);
        $result->setUri($this->getUri());
        $result->setPath('/$1/TaskTemplates');
        $result->setBody($this->wrapAtomEntry($taskTemplate));
        $result->addStatusCode(Resources::STATUS_CREATED);

        return $result;
    }
1055706
public function startProcess(Task $task)
    {
        $pid = pcntl_fork();
        $this->startFork($pid, $this->onStart, $task);
    }
1014584
protected function buildTask($archivename = null)
    {
        $this->readProperties();
        $archive = is_null($archivename) ? $this->time . '.tar.gz' : $archivename;
        $collection = $this->collectionBuilder();
        $collection
            ->taskPackageProject($archive);
        return $collection;
    }
147727
public function update(Task $task): Task
    {
        $id = $task->getId();

        $task->setId(null);

        $response = $this->client->put($this->prepareUrlForKey('update-task', ['id' => $id]), [], $task->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Task($responseData);
    }
1014109
private function _getCreateTaskContext(Task $task)
    {
        $result = new HttpCallContext();
        $result->setMethod(Resources::HTTP_POST);
        $result->setHeaders($this->_batchHeaders);
        $result->setUri($this->getUri());
        $result->setPath('/$1/Tasks');
        $result->setBody($this->wrapAtomEntry($task));
        $result->addStatusCode(Resources::STATUS_CREATED);

        return $result;
    }
101059
public function add(Task $task) : void
    {
        $this->index++;
        Util::put($this -> storage().$this->index.'.queue', serialize($task));
        $this -> updateIterator();
        Util::put($this -> storage().'_index', $this -> index);
    }
371635
public function push(TaskInterface $task)
    {
        return (bool) $this->getPersistence()->insert($this->getTableName(), [
            'message' => $this->serializeTask($task),
            'created_at' => $this->getPersistence()->getPlatForm()->getNowExpression()
        ]);
    }
983060
public function pushRequest(TaskEvent $event)
    {
        $task = $this->taskRepository->findByTaskId($event->getTask()->getUuid());
        if (!$task) {
            // current task is not managed by this bundle

            return;
        }

        $request = new Request(
            [],
            [],
            ['_task_id' => $event->getTask()->getUuid()],
            [],
            [],
            ['SERVER_NAME' => $task->getHost(), 'HTTPS' => $task->getScheme() === 'http' ? 'off' : 'on']
        );

        $this->requestStack->push($request);
    }
613599
private function createNode($name, $type = 'array', $default = null, $if = null, $then = null)
    {
        $node = $this->createTreeBuilder()->root($name, $type);

        if ($default !== null) {
            $node->defaultValue($default);
        }

        if ($if !== null && $then !== null) {
            $node->validate()->ifTrue($if)->thenInvalid(sprintf($then, $name));
        }

        return $node;
    }