@param array $basicData

@return TaskInterface
@throws InvalidTaskException
337199
public static function build($basicData)
    {
        $className = $basicData[TaskInterface::JSON_TASK_CLASS_NAME_KEY];

        if (class_exists($className) && is_subclass_of($className, TaskInterface::class)) {
            $metaData = $basicData[TaskInterface::JSON_METADATA_KEY];

            /** @var TaskInterface $task */
            $task = new $className($metaData[TaskInterface::JSON_METADATA_ID_KEY], $metaData[TaskInterface::JSON_METADATA_OWNER_KEY]);
            $task->setMetadata($metaData);
            $task->setParameter($basicData[TaskInterface::JSON_PARAMETERS_KEY]);

            if (isset($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY])) {
                $task->setCreatedAt(new \DateTime($metaData[TaskInterface::JSON_METADATA_CREATED_AT_KEY]));
            }

            return $task;
        }

        throw new InvalidTaskException;
    }
722801
protected function add($task) {
		if (is_string($task)) {
			$task = new $task($this->_config);
		}

		$class = get_class($task);
		if (!$task instanceof AbstractTask) {
			throw new InvalidArgumentException(
				"Cannot use '$class' as task, it is not implementing " . AbstractTask::class . '.'
			);
		}

		$this->tasks[$class] = $task;

		return $this;
	}
65192
public function addBehavior($bdata)
    {
        if ($bdata instanceof Behavior) {
            $behavior = $bdata;
            $behavior->setDatabase($this);
            $this->behaviors[$behavior->getName()] = $behavior;

            return $behavior;
        } else {
            $class = $this->getConfiguredBehavior($bdata['name']);
            $behavior = new $class();
            $behavior->loadFromXML($bdata);

            return $this->addBehavior($behavior);
        }
    }
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);
    }
1291086
public function fileUpload(array $fileData)
    {
        if (!isset($fileData['name'])) {
            throw new \InvalidArgumentException(
                'File data is invalid'
            );
        }

        $target = $this->uploadTarget($fileData['name']);

        $ret = move_uploaded_file($fileData['tmp_name'], $target);

        if ($ret === false) {
            $this->logger->warning(sprintf('Could not upload file %s', $target));

            return '';
        } else {
            $this->logger->notice(sprintf('File %s uploaded succesfully', $target));
            $basePath = $this->basePath();
            $target   = str_replace($basePath, '', $target);

            return $target;
        }
    }
607422
private function runTask($workflow, $taskServiceId, $taskId)
    {
        $task = $this->container->get("{$workflow}.task.{$taskServiceId}");

        if (!$task instanceof ExecutableTaskInterface) {
            throw new InvalidTaskClassException(
                "The service {$taskServiceId} must implement the ExecutableTaskInterface interface."
            );
        }

        if ($task instanceof ContainerAwareInterface) {
            $task->setContainer($this->container);
        }

        if ($task instanceof LoggerAwareInterface) {
            /** @var LoggerInterface $logger */
            $logger = $this->container->get('logger');
            $task->setLogger($logger);
        }

        $parameters = new ParameterBag();
        $parameterBagId = "{$workflow}{$taskId}";

        /** @var ProviderInterface $stateStorage */
        $stateStorage = $this->container->get('state_storage');

        // Try to load the state file.
        try {
            $stateStorage->load($parameterBagId, $parameters);
        } catch (IOException $ignored) {
        }

        if ($task instanceof ParameterAwareInterface) {
            $task->setParameters($parameters);
        }

        $task->execute();

        $stateStorage->persist($parameterBagId, $parameters);
    }
1213196
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $container = $this->getContainer();
        $taskList  = $container->get('tenside.tasks');
        $task      = $taskList->getTask($input->getArgument('taskId'));

        if (!$task) {
            throw new \InvalidArgumentException('Task not found: ' . $input->getArgument('taskId'));
        }

        $runner = new Runner($task, $container->get('tenside.taskrun_lock'), $container->get('logger'));

        return $runner->run(
            $container->get('kernel')->getLogDir() . DIRECTORY_SEPARATOR . 'task-' . $task->getId() . '.log'
        ) ? 0 : 1;
    }
894367
public function insert($insertData) {
		$this->provider('cache')->cacheClear('db', $this->getDao()->getTableName());
        $obj = $this->getConnection();
        $obj->insert($this->getDao()->getTableName(), $insertData);
        return $obj->count;
	}
810041
public function setInputData($inputData = array())
    {
        $this->inputData = $inputData;
        $this->logger->debug(__FUNCTION__, 'Input Data => ' . json_encode($this->inputData));

        return $this;
    }
392254
public function defineTask($taskName, $baseTask, $options)
    {
        $this->tasks['defined'][$taskName] = [
            'task' => $baseTask,
            'options' => $options
        ];
        return $this;
    }
964429
public function submit(array $inputData = [])
    {
        $this->validated = false;
        $this->isSubmitted = true;
        $this->isValid = true;

        /** @var ElementInterface $element */
        foreach ($this->elements() as $name => $element) {
            if ($element->isDisabled()) {
                continue;
            }
            $value = $inputData[$name] ?? '';
            $this->rawData[$name] = $value;
            $value = $this->filter($name, $value);
            $this->data[$name] = $value;
            $element->withValue($value);

            // only validate elements which are not disabled.
            if (! $this->validate($name, $element->value())) {
                $this->isValid = false;
            }
        }
    }
272961
public static function nPost(string $name, $data, $workerID = -1)
    {
        $task = TaskParser::getInstance()->getTask($name);
        $paramClass = $task['Task']->paramClass;
        return static::post(new TaskInfo(new $task['className'], new $paramClass($data)), $workerID);
    }
203631
static function do_works()
	{
		$tasker = new self;
		$tasks = glob($tasker->task_dir().'/*.json');
		shuffle($tasks);
		foreach($tasks as $file)
		{
			$content = file_get_contents($file);
			$task_data = json_decode($content, true);
			if(!$task_data)
			{
				\bors_debug::syslog('error-tasks-airbase', "Can't decode json in '$file': '".$content."'");
				continue;
			}

			$worker = $task_data['worker'];
			$data	= $task_data['data'];

			if(preg_match('/^(\w+)->(\w+)$/', $worker, $m))
			{
				list($worker_class, $worker_method) = [$m[1], $m[2]];

				$worker_method = 'do_work_'.$worker_method;

				if(is_array($data))
					$id = @$data['id'];
				else
					$id = $data;

				$worker = bors_load($worker_class, $id);

				if(!$worker)
				{
					\bors_debug::syslog('tasks-airbase-error', "Can't load $worker_class($id) for run ->$worker_method()");
					continue;
				}

				$error = $worker->$worker_method($data);

				if($error)
					\bors_debug::syslog('error-task-json', "Task error in '$file': $worker_class->$worker_method returned " . $error);
				else
					unlink($file);

				continue;
			}

			\bors_debug::syslog('error-task-json', "Unknown worker format in '$file': ".$worker);
		}
	}
940050
public function addTask()
    {
        $args = func_get_args();
        list($name, $description, $dependencies, $work) = $this->parseArguments($args);

        # Existing command
        #
        if ($work instanceof BaseCommand) {
            if ($name) {
                $work->setName($name);
            }
            $task = $work;
        } else {
            $task = new Command($name);

            switch (true) {
                # Basic closure
                #
                case $work instanceof \Closure:
                    $work = $work->bindTo($task);
                    $task->setCode($work);
                    break;

                case is_array($work):
                    if (is_callable(end($work))) {
                        # Injector
                        #
                        reset($work);
                        $injector = $this->injector;
                        $task->setCode($injector($work, $task));
                    } else {
                        # Group
                        #
                        $task = new GroupCommand($name, $this, $work);
                    }

                    break;
                default:
                    throw new \InvalidArgumentException("Unrecognised task signature for $name");
            }
        }

        if ($description) {
            $task->setDescription($description);
        }

        parent::add($task);
        $this->setTaskDependencies($name, $dependencies);

        return $task;
    }
855096
protected function process(array $arguments): void
    {
        $result = $this
            ->getShell()
            ->process($arguments);
        if ($result instanceof ShellResultInterface) {
            $command = $result->getCommand();
            $parameters = $command->getParameters();
            if (array_key_exists('task', $parameters) === false) {
                throw new TaskParameterMissing($command);
            }

            try {
                $task = $this->getTask($parameters['task']);
            } catch (ServiceLocatorException $exception) {
                throw new TaskNotFound($command, $exception);
            }

            try {
                $task->execute(
                    $result->getData()
                );
            } catch (TaskException $exception) {
                throw new TaskExecuteFailed($command, $exception);
            }
        }
    }
901623
public static function restore(array $data)
    {
        if (!isset($data['invocable'], $data['params'])){
            return null;
        }
        /**
         * @var $task Task
         */
        $class = self::class;
        $task = new $class();
        if (isset($data['report'])) {
            $task->setReport($data['report']);
        }
        if (isset($data['status'])) {
            $task->setStatus($data['status']);
        }
        if (isset($data['id'])) {
            $task->setId($data['id']);
        }
        if (isset($data['added'])) {
            $task->setCreationDate($data['added']);
        }
        if (isset($data['owner'])) {
            $task->setOwner($data['owner']);
        }
        if (isset($data['label'])) {
            $task->setLabel($data['label']);
        }
        if (isset($data['type'])) {
            $task->setType($data['type']);
        }
        if (isset($data['added'])) {
            $task->setType($data['added']);
        }
        if(isset($data['invocable'])) {
            $task->setInvocable($data['invocable']);
        }
        if (isset($data['params'])) {
            $task->setParameters($data['params']);
        }
        return $task;
    }
1342402
public function mapToObject(array $objectData)
    {
        if ($objectData === []) {
            throw new Exception\InvalidObjectDataException('The array with object data was empty, probably object not found or access denied.', 1277974338);
        }

        if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) {
            return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']);
        } else {
            $className = $objectData['classname'];
            $classSchema = $this->reflectionService->getClassSchema($className);

            $object = unserialize('O:' . strlen($className) . ':"' . $className . '":0:{};');
            $this->persistenceSession->registerObject($object, $objectData['identifier']);
            if ($classSchema->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
                $this->persistenceSession->registerReconstitutedEntity($object, $objectData);
            }
            if ($objectData['properties'] === []) {
                if (!$classSchema->isLazyLoadableObject()) {
                    throw new PersistenceException('The object of type "' . $className . '" is not marked as lazy loadable.', 1268309017);
                }
                $persistenceManager = $this->persistenceManager;
                $persistenceSession = $this->persistenceSession;
                $dataMapper = $this;
                $identifier = $objectData['identifier'];
                $modelType = $classSchema->getModelType();
                $object->Flow_Persistence_LazyLoadingObject_thawProperties = function ($object) use ($persistenceManager, $persistenceSession, $dataMapper, $identifier, $modelType) {
                    $objectData = $persistenceManager->getObjectDataByIdentifier($identifier);
                    $dataMapper->thawProperties($object, $identifier, $objectData);
                    if ($modelType === ClassSchema::MODELTYPE_ENTITY) {
                        $persistenceSession->registerReconstitutedEntity($object, $objectData);
                    }
                };
            } else {
                $this->thawProperties($object, $objectData['identifier'], $objectData);
            }

            return $object;
        }
    }