Includes a file path using output buffering.
Ensures that vars are available.
@param string $filePath Absolute path to the view file.
@param array $extraParams Parameters that should be available to the view.
@return string
327395
public function makeFileContents($filePath, $extraParams = [])
    {
        if (!strlen($filePath) ||
            !File::isFile($filePath) ||
            (!File::isLocalPath($filePath) && Config::get('cms.restrictBaseDir', true))
        ) {
            return '';
        }

        if (!is_array($extraParams)) {
            $extraParams = [];
        }

        $vars = array_merge($this->vars, $extraParams);

        $obLevel = ob_get_level();

        ob_start();

        extract($vars);

        // We'll evaluate the contents of the view inside a try/catch block so we can
        // flush out any stray output that might get out before an error occurs or
        // an exception is thrown. This prevents any partial views from leaking.
        try {
            include $filePath;
        }
        catch (Exception $e) {
            $this->handleViewException($e, $obLevel);
        }
        catch (Throwable $e) {
            $this->handleViewException(new FatalThrowableError($e), $obLevel);
        }

        return ob_get_clean();
    }
886575
public function locate($filePath)
    {
        $file = $filePath;
        if (!is_file($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" does not exist.',
                                            $filePath));
        }

        if (!is_readable($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" is not readable.',
                                            $filePath));
        }

        $pathInfo = pathinfo($filePath);
        if (!isset($pathInfo['extension'])
            || !in_array($pathInfo['extension'], $this->supportedExtensions)
        )
        {
            throw new FileException(sprintf('Invalid file extension! Supported file extensions: %s',
                implode(', ', $this->supportedExtensions)));
        }

        return realpath($file);
    }
588115
public function saveToFile($content, $additionalPath = '')
    {
        $path = $this->realPath($additionalPath);
        
        // If the path does not exists create the directory
        $this->createTargetDirectory($path);
        
        // If the file exists but isn't writeable we need to throw an exception
        if (file_exists($path) && !is_writable($path)) {
            throw new Exception('The file "' . $path . '" isn\'t writable!');
        }
        
        return file_put_contents($path, $content);
    }
8144
public function loadFile($filePath) {
        require_once (substr($filePath, 0, 1) != '/' && substr($filePath, 1, 1) != ':')
            ? $this->basePath . DIRECTORY_SEPARATOR . $filePath : $filePath;
    }
178954
protected function setFilePath($filePath)
	{
		if ( ! is_string($filePath))
		{
			throw new \InvalidArgumentException('File path must be a string type.');
		}
		
		if (preg_match('~^(\w+:)?//~', $filePath) || is_link($filePath))
		{
			throw new \InvalidArgumentException('File path must be a local path.');
		}
		
		$filePath = realpath($filePath);
		
		if ( ! is_file($filePath))
		{
			throw new TranscoderException('File path not found.');
		}
		
		$this->filePath = $filePath;
		
		return $this;
	}
112070
public function getPageListFromPageTransclusions( $pageName, array $extraParams = [] ) {
		$params = array_merge( $extraParams, [
			'list' => 'embeddedin',
			'eititle' => $pageName,
		] );
		return $this->runQuery( $params, 'eicontinue', 'embeddedin' );
	}
376106
public function getPath($relativePath, $fileName = null, $ext = '.php')
    {
        $path = Path::join($this->dir, $relativePath);

        return is_null($fileName) ? $path : Path::join($path, $fileName . $ext);
    }
1180814
public function getSortPath($route, $column, $order, $extraParams = array())
    {
        $params = array(
            $this->getActionParameterName() => $this->getSortActionParameterName(),
            $this->getDatagridParameterName() => $this->getName(),
            $this->getSortColumnParameterName() => $column,
            $this->getSortOrderParameterName() => $order,
        );
        return $this->container->get('router')->generate($route, array_merge($params, $extraParams));
    }
338654
public function getFilePath($filePath)
    {
        $composerFiles = [];
        foreach ($this->alias as $name => $path) {
            $composerFiles[] = $path . '/' . $filePath;
        }

        return FileHelper::getFirstExistingFileArray($composerFiles);
    }
724155
public function to($path, $extra = [], $secure = null)
    {
        // First we will check if the URL is already a valid URL. If it is we will not
        // try to generate a new one but will simply return the URL as is, which is
        // convenient since developers do not always have to check if it's valid.
        if ($this->isValidUrl($path)) {
            return $path;
        }

        $tail = implode('/', array_map(
            'rawurlencode', (array) $this->formatParameters($extra))
        );

        // Once we have the scheme we will compile the "tail" by collapsing the values
        // into a single string delimited by slashes. This just makes it convenient
        // for passing the array of parameters to this URL as a list of segments.
        $root = $this->formatRoot($this->formatScheme($secure));

        [$path, $query] = $this->extractQueryString($path);

        return $this->format(
            $root, '/'.trim($path.'/'.$tail, '/')
        ).$query;
    }
490733
public function uploadFile($path = '', $file = null, $extraHeaders = null)
    {
        if (file_exists($file['path'])) {
            $headers = [
                'Content-Length' => (string)$file['size']
            ];
            $finfo = finfo_open(FILEINFO_MIME);
            $mime = finfo_file($finfo, $file['path']);
            $parts = explode(";", $mime);
            $headers['Content-Type'] = $parts[0];
            $headers['Etag'] = md5_file($file['path']);
            $headers['Sha256'] = hash_file('sha256', $file['path']);
            $headers = isset($extraHeaders) ? array_merge($headers, $extraHeaders) : $headers;

            return $this->sendRequest(
                'PUT',
                $path . $file['name'],
                [
                    'headers' => $headers,
                    'body' => fopen($file['path'], 'rb'),
                    'expect' => true
                ]
            );
        }
    }
329652
protected function realPath($additionalPath)
    {
        if (substr($additionalPath, 0, 1) === '/') {
            $path = $additionalPath;
        } else if ($additionalPath !== '') {
            $path = $this->path . $additionalPath;
        } else {
            $path = $this->path;
        }
    
        return $path;
    }
1364288
public function compile($templatePath, Array $templateData, $filePath)
    {
        $template = $this->filesystem->get($templatePath);

        $compiled = $this->compiler->compile($template, $templateData);

        $this->makeDirectory(dirname($filePath));

        $this->filesystem->put($filePath, $compiled);

        return $filePath;
    }
56804
function save($filepath='') {
        $ret = $this->root->innertext();
        if ($filepath!=='') file_put_contents($filepath, $ret);
        return $ret;
    }
25126
static function dirpath( $filepath )
    {
        $filepath = eZDir::cleanPath( $filepath, self::SEPARATOR_UNIX );
        $dirPosition = strrpos( $filepath, '/' );
        if ( $dirPosition !== false )
            return substr( $filepath, 0, $dirPosition );
        return $filepath;
    }
746571
protected function prepareUrls($filePath, array $urls = [], $forceRefresh = false, $cacheOnly = false, $shuffle = true)
    {
        $fileExists = file_exists($filePath);

        if ($cacheOnly) {
            if (!$fileExists) {
                $this->log->debug("Cache only mode enabled, but $filePath does not exist !");

                return [];
            }
            $this->log->debug("Cache only mode enabled, only loading content from $filePath");

            return [$filePath];
        } else {
            if ($shuffle) {
                shuffle($urls);
            }

            if ($forceRefresh) {
                $this->log->debug("Refresh forced, skipping cached content from $filePath");

                return $urls;
            }
            if ($fileExists) {
                array_unshift($urls, $filePath);
            }

            return $urls;
        }
    }
3136
public function deleteFile($additionalPath = '')
    {
        $path = $this->testPath($this->realPath($additionalPath));
        
        if ($path === false) {
            return false;
        }
        
        return unlink($path);
    }