Fetch the destination files from the task and return and array of SplInfo.

@param Task $task
@return SplFileInfo[]
549344
protected function fetchDestinations(Task $task)
    {
        $sources = [];

        foreach ($task->getDestinations() as $source) {
            // locate new resource and merge them to the existing sources
            $sources[] = new SplFileInfo($source);
        }

        return $sources;
    }
1317812
private function processStreamCallback(string $task, ...$params)
    {
        if (! isset($this->stream)) {
            throw new \RuntimeException('Stream is detached');
        }

        $task = strtolower($task);
        $fn = 'f';
        if ($this->streamType === 'ZLIB') {
            if ($task === 'stat') {
                return false;
            }
            $fn = 'gz';
        }
        // default using f$task -> eg fopen() on gzip using gzopen
        $fn   .= $task;
        if (! function_exists($fn)) {
            return false;
        }
        switch ($task) {
            case 'seek':
            case 'write':
                if ($task === 'seek' && ! $this->seekable) {
                    throw new \RuntimeException('Stream is not seekable');
                } elseif ($task === 'write' && ! $this->writable) {
                    throw new \RuntimeException('Cannot write to a non-writable stream');
                }

                if (isset($params[1])) {
                   return $fn($this->stream, $params[0], $params[1]);
                }
                return $fn($this->stream, $params[0]);
            case 'read':
                return $fn($this->stream, $params[0]);
            default:
                return $fn($this->stream, ...$params);
        }
    }
742406
protected static function _discover_tasks()
	{
		$result = array();
		$files = \Finder::instance()->list_files('tasks');

		if (count($files) > 0)
		{
			foreach ($files as $file)
			{
				$task_name = str_replace('.php', '', basename($file));
				$class_name = '\\Fuel\\Tasks\\'.$task_name;

				require $file;

				$reflect = new \ReflectionClass($class_name);

				// Ensure we only pull out the public methods
				$methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);

				$result[$task_name] = array();

				if (count($methods) > 0)
				{
					foreach ($methods as $method)
					{
						strpos($method->name, '_') !== 0 and $result[$task_name][] = $method->name;
					}
				}
			}
		}

		return $result;
	}
1046304
protected function cache($task, $data = null)
    {
        $config = array_merge($this->cache, $task['cache']);
        if (! $config['enable']) {
            return null;
        }
        if (! isset($config['dir'])) {
            user_error('cache dir is not defined', E_USER_WARNING);
            return null;
        }
        $url = $task['opt'][CURLOPT_URL];
        $post = null;
        if (true == $config['verifyPost'] && ! empty($task['opt'][CURLOPT_POSTFIELDS])) {
            $post = $task['opt'][CURLOPT_POSTFIELDS];
        }
        $file = rtrim($config['dir'], '/') . '/';
        $file .= $this->getCacheFile($url, $post);
        if (! isset($data)) {
            if (file_exists($file)) {
                $time = time();
                $mtime = filemtime($file);
                if ($time - $mtime < $config['expire']) {
                    return unserialize(gzuncompress(file_get_contents($file)));
                }
            }
        } else {
            if (! isset($data['cache'])) {
                $data['cache'] = array();
            }
            $data['cacheFile'] = $file;
            unset($data['curl']);
            $dir = dirname($file);
            $dir1 = dirname($dir);
            if (! is_dir($dir1)) {
                mkdir($dir1);
            }
            if (! is_dir($dir)) {
                mkdir($dir);
            }
            // Cache response from downloaded file.
            if (isset($task['fileMeta']['uri'])) {
                $data['body'] = file_get_contents($task['fileMeta']['uri']);
            }
            file_put_contents($file, gzcompress(serialize($data), $config['compress']), LOCK_EX);
        }
        return null;
    }
779004
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();

        //====================================================================//
        // Initial Response
        $response = self::getEmptyResponse($task);

        //====================================================================//
        // Safety Check - Minimal Parameters
        //====================================================================//
        $inputs = self::validateInputs($task);
        if (!$inputs) {
            return $response;
        }

        //====================================================================//
        // Execute Action
        switch ($task->name) {
            //====================================================================//
            //  READING A FILE INFORMATIONS
            case SPL_F_ISFILE:
                $response->data = Splash::file()->isFile($inputs['path'], $inputs['md5']);

                break;
            //====================================================================//
            //  READING A FILE CONTENTS
            case SPL_F_GETFILE:
                $response->data = Splash::file()->readFile($inputs['path'], $inputs['md5']);

                break;
            default:
                Splash::log()->err('File - Requested task not found => '.$task->name);

                break;
        }

        //====================================================================//
        // Task results prot treatment
        if (false != $response->data) {
            $response->result = true;
        }

        return $response;
    }
667116
protected function returnTaskJson(TaskInterface $task, array $extraData = [])
    {
        return $this->returnJson([
            'success' => true,
            'data' => [
                'extra' => $extraData,
                'task' => $this->getTaskLogReturnData($task->getId())
            ]
        ]);
    }
563223
public function addBulk(array $tasks) {

        $result = [];

        foreach($tasks as $name => $task) {

            if ( empty($task['class']) ) {

                $this->logger->warning("Missing class for task $name");
                $result[] = false;

            } else {

                $result[] = $this->add($name, $task['class'], empty($task['description']) ? null : $task['description']);

            }

        }

        return $result;

    }
1327460
private function getFiles(): array
	{
		$result = [];
		$files = Finder::find('*')
			->in($this->getFullPath());
		foreach ($files as $file) {
			$result[] = new FileInfo($file);
		}
		usort($result, function ($a, $b) {
			if ($a->isDir == $b->isDir) {
				return strcmp($a->name, $b->name);
			} else {
				if ($a->isDir) {
					return -1;
				} else {
					return 1;
				}
			}
		});
		return $result;
	}
133087
public function build(array &$errors = null):array {
		$updatedTasks = [];
		foreach($this->taskList as $pathMatch => $task) {
			if($task->build($errors)) {
				$updatedTasks []= $task;
			}
		}

		return $updatedTasks;
	}
1183198
public function updateTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->update($this->tasklist, $task->id, $task);
    }
391851
private static function get_section_backup_information($task) {

        $contentinfo = array(
            'sectionid'  => $task->get_sectionid(),
            'title'      => $task->get_name(),
            'directory'  => 'sections/' . 'section_' . $task->get_sectionid());

        // Now get section settings
        // Calculate prefix to find valid settings
        $prefix = basename($contentinfo['directory']);
        $settingsinfo = array();
        foreach ($task->get_settings() as $setting) {
            // Discard ones without valid prefix
            if (strpos($setting->get_name(), $prefix) !== 0) {
                continue;
            }
            // Validate level is correct (section)
            if ($setting->get_level() != backup_setting::SECTION_LEVEL) {
                throw new backup_controller_exception('setting_not_section_level', $setting);
            }
            $settinginfo = array(
                'level'    => 'section',
                'section'  => $prefix,
                'name'     => $setting->get_name(),
                'value'    => $setting->get_value());
            $settingsinfo[$setting->get_name()] = (object)$settinginfo;
        }
        return array($contentinfo, $settingsinfo);
    }
517423
public function getFileInfo(string $destination): SplFileInfo
    {
        $name = Normalizer::normalizeClassname($this->getName());
        $path = rtrim($destination, '/\\').DIRECTORY_SEPARATOR.$name.'.php';

        return new SplFileInfo($path);
    }
281871
public function getTasksListeners($task, $event, $flatten = false)
    {
        // Get events
        $task = $this->builder->buildTaskFromClass($task);
        $handle = $this->getEventHandle($task, $event);
        $events = $this->events->getListeners($handle);

        // Flatten the queue if requested
        foreach ($events as $key => $listener) {
            if ($flatten && $listener instanceof ClosureTask && $stringTask = $listener->getStringTask()) {
                $events[$key] = $stringTask;
            } elseif ($flatten && $listener instanceof AbstractTask) {
                $events[$key] = $listener->getSlug();
            }
        }

        return $events;
    }
450419
public function getTask($task, array $macroOptions = [])
    {
        $script = Arr::get($this->tasks, $task, '');

        if ($script == '') {
            throw new \Exception(sprintf('Task "%s" is not defined.', $task));
        }

        $options = array_merge($this->getTaskOptions($task), $macroOptions);

        $parallel = Arr::get($options, 'parallel', false);

        $confirm = Arr::get($options, 'confirm', null);

        return new Task($this->getServers($options), $options['as'], $script, $parallel, $confirm);
    }
404214
protected function _getFileData($_files) {
		$return_files = [];
		if (is_array($_files)) {
			foreach ($_files as $fkey => $fvalue) {
				if (is_array($fvalue)) {
					foreach ($fvalue as $varname => $varpair) {
						if (is_array($varpair)) {
							foreach ($varpair as $fieldname => $varvalue) {
								$return_files[$fkey][$fieldname][$varname]=$varvalue;
							}
						} else {
							$return_files[$fkey] = $fvalue;
						}
					}
				}
			}
		}
		return $return_files;
	}
487335
public function update(Task $task)
    {
        $this->om->persist($task);
        $this->om->flush();

        $this->notify(NotifierInterface::MESSAGE_UPDATE);

        return $task;
    }
1060095
private static function get_course_backup_information($task) {

        $contentinfo = array(
            'courseid'   => $task->get_courseid(),
            'title'      => $task->get_name(),
            'directory'  => 'course');

        // Now get course settings
        // Calculate prefix to find valid settings
        $prefix = basename($contentinfo['directory']);
        $settingsinfo = array();
        foreach ($task->get_settings() as $setting) {
            // Discard ones without valid prefix
            if (strpos($setting->get_name(), $prefix) !== 0) {
                continue;
            }
            // Validate level is correct (course)
            if ($setting->get_level() != backup_setting::COURSE_LEVEL) {
                throw new backup_controller_exception('setting_not_course_level', $setting);
            }
            $settinginfo = array(
                'level'    => 'course',
                'name'     => $setting->get_name(),
                'value'    => $setting->get_value());
            $settingsinfo[$setting->get_name()] = (object)$settinginfo;
        }
        return array($contentinfo, $settingsinfo);
    }