Returns rendered file info content
@param \SplFileInfo $file
@param \gplcart\core\Controller $controller
@return string
338315
protected function viewInfo($file, $controller)
    {
        $data = array(
            'file' => $file,
            'perms' => gplcart_file_perms($file->getPerms()),
            'filesize' => gplcart_file_size($file->getSize())
        );

        return $controller->render('file_manager|readers/info', $data);
    }
534197
public function getControllerDefaultRoutes($controller, $file)
    {
        $array = array();
        if (isset($this->config['app']['routes'])) {
            $routes = $this->config['app']['routes'];
            if (!is_int(key($routes))) {
                $routes = array($routes);
            }
            foreach ($routes as $item) {
                if (isset($item[$controller])) {
                    $array[] = $item[$controller];
                }
            }
        }

        if(isset($this->config['app']['index'])) {
            $index = $this->config['app']['index'];
            if (strpos($file, $index) !== false) {
                $array[] = $this->cleanUrl(substr($file, 0, strpos($file, $index)));
            }
        }
        $array[] = $this->cleanUrl($file);

        return $array;
    }
378099
protected function getControllerActionMetadata($controller)
    {
        $controllerClass = get_class($controller[0]);

        $metadata = $this->metadataFactory->getMetadataForClass($controllerClass);

        $controllerMetadata = $metadata->getOutsideClassMetadata();

        $action_metadatas = null;
        if (array_key_exists($controller[1], $controllerMetadata->methodMetadata)) {
            $action_metadatas = $controllerMetadata->methodMetadata[$controller[1]];
        }

        return $action_metadatas;
    }
1349799
private function getFilePath($controller = false, $action = false){
		$controller = $controller ?: $this->_controller;
		$action = $action ?: $this->_action;

		$cacheFileName = $this->generateFileName($controller, $action);

		$path = $this->getAssetsUrl() . DIRECTORY_SEPARATOR . $this->folder . DIRECTORY_SEPARATOR . $cacheFileName;

		return $path;
	}
876680
protected static function getFilePath(\SplFileInfo $file)
    {
        $path = $file->getPathname();

        $path = trim(str_replace('\\', '/', $path));

        return $path;
    }
387726
protected function fileToClass(SplFileInfo $file)
    {
        preg_match('/.*namespace\s([^\;]+)?/i', $file->getContents(), $match);

        if (isset($match[1])) {
            $class = $match[1].'\\'.$file->getBasename('.php');
            if (class_exists($class)) {
                return $class;
            }
        }
    }
440913
private function getFileKey(\SplFileInfo $file)
    {
        $key = null;

        if ($h = @fopen($file, 'r')) {
            rawurldecode(rtrim(fgets($h)));
            $value = stream_get_contents($h);
            fclose($h);
            $key = substr($value, 0, strpos($value, "\n"));
        }

        return $key;
    }
228741
public function submit($controller)
    {
        $submitted = $controller->getSubmitted();

        /* @var $file \SplFileInfo */
        $file = reset($submitted['files']);

        $directory = $submitted['destination'];
        $pathinfo = pathinfo($submitted['destination']);

        if (!empty($pathinfo['extension'])) {
            $directory = trim($pathinfo['dirname'], '.');
        }

        $result = true;

        if ($directory && !file_exists($directory)) {
            $result = mkdir($directory, 0777, true);
        }

        if ($result && !empty($pathinfo['basename'])) {
            $result = touch($submitted['destination']);
        }

        $query = array(
            'cmd' => 'list',
            'path' => $this->getRelativeFilePath($file->getRealPath())
        );

        if ($result) {
            return array(
                'severity' => 'success',
                'redirect' => $controller->url('', $query),
                'message' => $this->translation->text('File has been created')
            );
        }

        return array(
            'severity' => 'warning',
            'redirect' => $controller->url('', $query),
            'message' => $this->translation->text('File has not been created')
        );
    }
629624
public function getFileContent(File $file)
	{
		$filePath = $this->getFilesystemPath($file);
		$fileContent = file_get_contents($filePath);

		return $fileContent;
	}
229445
protected function getFileContents($file)
    {
        if ($file instanceof ModuleResource) {
            $path = $file->getPath();
        } else {
            $path = Director::baseFolder() . '/' . $file;
        }
        if (!file_exists($path)) {
            return null;
        }
        $content = file_get_contents($path);

        // Remove UTF-8 BOM
        if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf)) {
            $content = substr($content, 3);
        }

        return $content;
    }
207198
public function getBinary(\SplFileInfo $file): string
    {
        if (!($file instanceof \SplFileObject)) {
            $file = $file->openFile();
        } else {
            $file->rewind();
        }
        if ($file instanceof \SplTempFileObject) {
            $binary = '';
            while ($file->valid()) {
                $binary .= $file->fread(self::READ_LENGTH);
            }
        } else {
            if (!($file instanceof \SplFileObject)) {
                $file = $file->openFile();
            }
            $binary = $file->fread($file->getSize());
        }
        return $binary;
    }
1292048
public function content()
    {
        if ($this->app->getMatchRoute()) {
            $actionName = strtolower(preg_replace('/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', '-', $this->app->getActionName()));

            $fileArray = [
                strtolower($this->app->getModuleName()),
                str_replace('controller', '', strtolower($this->app->getControllerName())),
                $actionName . '.phtml'
            ];

            $file = implode('/', $fileArray);
        } else {
            $viewManager = $this->config->get('view_manager');
            $file = $viewManager['template_map']['error/404'];
        }

        $this->render($file);
    }
1281821
public function filter(\SplFileInfo $file)
    {
        $fh = fopen($file->getPathName(), 'r');
        $content = fread($fh, $this->length);
        fclose($fh);

        return false !== strpos($content, $this->contains);
    }
517083
public function submit($controller)
    {
        set_time_limit(0);

        $path = null;
        $errors = $success = 0;

        /* @var $file \SplFileInfo */
        foreach ($controller->getSubmitted('files', array()) as $file) {
            $path = $file->getRealPath();
            gplcart_file_delete_recursive($path, $errors, $success);
        }

        $query = array(
            'cmd' => 'list',
            'path' => isset($path) ? $this->getRelativeDirectory($path) : ''
        );

        $vars = array('@num_success' => $success, '@num_errors' => $errors);

        return array(
            'redirect' => $controller->url('', $query),
            'severity' => empty($errors) ? 'success' : 'warning',
            'message' => $this->translation->text('Deleted @num_success, errors: @num_errors', $vars)
        );
    }
702376
protected function normalizeFileInfo(SplFileInfo $file, $base = null)
	{
		$normalized = array(
			'type'      => $file->getType(),
			'path'      => ($base ? substr($file->getPathname(), strlen($base)) : $file->getPathname()),
			'timestamp' => $file->getMTime()
		);

		if ($normalized['type'] === 'file')
		{
			$normalized['size'] = $file->getSize();
		}

		return $normalized;
	}
142955
public function view($file, $controller)
    {
        $this->controller = $controller;

        $path = $file->getRealPath();
        $params = $controller->getQuery(null, array(), 'array');

        $pager_options = array(
            'max_pages' => 5,
            'query' => $params,
            'total' => $this->getTotal($path, $params),
            'limit' => $this->controller->getModuleSettings('file_manager', 'limit')
        );

        $pager = $this->controller->getPager($pager_options);
        $params['limit'] = $pager['limit'];

        return array(
            'file_manager|commands/list' => array(
                'pager' => $pager['rendered'],
                'filters' => $this->scanner->getFilters(),
                'sorters' => $this->scanner->getSorters(),
                'files' => $this->getFilesListing($path, $params)
            ));
    }
430097
public function getSplFileInfo(): \SplFileInfo
    {
        if (null !== $this->splFileInfo && $this->path === $this->splFileInfo->getRealPath()) {
            return $this->splFileInfo;
        }
        $this->assertExists();

        return $this->createSplFileInfo();
    }