Saves any additional input into the current task object if the task
class matches.

@param array $submittedData array containing the data submitted by the user
@param AbstractTask $task reference to the current task object
489045
public function saveAdditionalFields(
        array $submittedData,
        AbstractTask $task
    ) {
        /** @var $task ReIndexTask */
        if (!$this->isTaskInstanceofReIndexTask($task)) {
            return;
        }

        $task->setRootPageId($submittedData['site']);

        $indexingConfigurations = [];
        if (!empty($submittedData['indexingConfigurations'])) {
            $indexingConfigurations = $submittedData['indexingConfigurations'];
        }
        $task->setIndexingConfigurationsToReIndex($indexingConfigurations);
    }
1054712
public function addTask(Task $task): Task
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use create() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->create($task);
    }
1168630
private function convertTaskToArray(Task $task, $addOutput = false, $outputOffset = null)
    {
        $data = [
            'id'         => $task->getId(),
            'status'     => $task->getStatus(),
            'type'       => $task->getType(),
            'created_at' => $task->getCreatedAt()->format(\DateTime::ISO8601),
            'user_data'  => $task->getUserData()
        ];

        if (true === $addOutput) {
            $data['output'] = $task->getOutput($outputOffset);
        }

        return $data;
    }
176519
public function submit($submittedData, $clearMissing = true)
    {
        if ($this->submitted) {
            throw new AlreadySubmittedException('A form can only be submitted once');
        }

        $this->submitted = true;

        return $this;
    }
310990
public function add(TaskInterface $task): bool
	{
		if ($this->exists($task))
			return false;

		$this->tasks[] = $task;

		return true;
	}
1298778
public function submissionSaveData(array $formData)
    {
        // remove empty values
        $formData = array_filter($formData);

        // get array of files to upload
        $files = [];
        foreach ($formData as $field => $value) {
            if (Request::hasFile($field)) {
                $files[$field] = Request::file($field);
                unset($formData[$field]);
            }
        }

        // save form submission
        $form_submission = new FormSubmission;
        $form_submission->form_block_id = $this->_block->id;
        $form_submission->content = serialize($formData);
        $form_submission->sent = 0;
        $form_submission->from_page_id = PageBuilder::pageId();
        $form_submission->save();
        $form_submission->uploadFiles($files);
        return $form_submission;
    }
1095004
private function captureInput(array $eventData)
    {
        $inputData = [
            'text' => FallbackCommand::CMD,
        ];

        if (empty($eventData['replyToken'])) {
            throw new \InvalidArgumentException("Require `replyToken` to run.");
        }

        if (empty($eventData['source']['userId'])) {
            throw new \InvalidArgumentException("Require `userId` to run.");
        }

        $inputData['replyToken'] = $eventData['replyToken'];
        $inputData['userId'] = $eventData['source']['userId'];
        $type = strtolower(@$eventData['type']);

        switch ($type) {
            case Constants::REVEIVE_TYPE_FOLLOW:
                $inputData['text'] = ':follow';
                break;

            case Constants::REVEIVE_TYPE_MESSAGE:
                $inputData['text'] = $this->captureReceiveMessageText($eventData);
                break;

            default:
                throw new \RuntimeException("Unsupported event type `$type`.");
        }

        return new Input($inputData);
    }
587228
public function saveEvent($eventData)
    {
        $serializedEvent = $this->jsonSerializer->serialize($eventData);
        $insertData = ['event_id' => md5($serializedEvent . time()), 'data' => $serializedEvent];
        $this->getConnection()->insertOnDuplicate($this->getMainTable(), $insertData, ['data']);
    }
418064
public void register(Task task) {
        Optional.ofNullable(task)
                .filter(t -> t.getTask() != null)
                .filter(t -> StringUtils.hasText(t.getName()))
                .ifPresent(t -> checkTaskMap.put(t.getName(), t));
    }
1157559
public function updateTask(Task $task): Task
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use update() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->update($task);
    }
1290487
@Override
    public <T> Future<T> submit(Callable<T> task) {
        ExecutorService executor = getScheduledExecutor();
        try {
            Callable<T> taskToUse = task;
            if (this.errorHandler != null) {
                taskToUse = new DelegatingErrorHandlingCallable<T>(task, this.errorHandler);
            }
            return executor.submit(taskToUse);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
        }
    }
667116
protected function returnTaskJson(TaskInterface $task, array $extraData = [])
    {
        return $this->returnJson([
            'success' => true,
            'data' => [
                'extra' => $extraData,
                'task' => $this->getTaskLogReturnData($task->getId())
            ]
        ]);
    }
847487
private function saveAllObjects(array $allData): void
    {
        $fileSaved = @file_put_contents($this->databaseFilePath, Serializer::serialize($allData));

        if ($fileSaved === false) {
            throw new \RuntimeException(sprintf('Failed to save file "%s"', $this->databaseFilePath));
        }
    }
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');

        }
    }
1177396
public <T> FutureTask<T> submit(Callable<T> task)
    {
        return submit(newTaskFor(task));
    }
1266124
public function restore_instance_data_from_backup(\restore_task $task, array $data) {
        $courseid = $task->get_courseid();
        $context = $this->get_instance_context($courseid);
        $editablefields = $this->get_editable_fields($courseid);
        $records = api::get_instance_fields_data($editablefields, $courseid);
        $target = $task->get_target();
        $override = ($target != \backup::TARGET_CURRENT_ADDING && $target != \backup::TARGET_EXISTING_ADDING);

        foreach ($records as $d) {
            $field = $d->get_field();
            if ($field->get('shortname') === $data['shortname'] && $field->get('type') === $data['type']) {
                if (!$d->get('id') || $override) {
                    $d->set($d->datafield(), $data['value']);
                    $d->set('value', $data['value']);
                    $d->set('valueformat', $data['valueformat']);
                    $d->set('contextid', $context->id);
                    $d->save();
                }
                return;
            }
        }
    }
422981
public function setTaskStatus(AbstractTask $task, $status) {
        Database::prepare(
            'UPDATE `##maj_admintasks`'.
            ' SET majat_status = :status'.
            ' WHERE majat_name = :name'
        )->execute(array(
                'name' => $task->getName(),
				'status' => $status ? 'enabled' : 'disabled'
        ));
    }