public function readFile($filename, Environment $environment, $commitSha = null)
    {
        $commitSha = $this->normalizeSha($environment, $commitSha);
        $cacheKey = implode(':', ['raw', $environment->project, $filename, $commitSha]);
        $data = $this->cache->fetch($cacheKey);
        if (!is_array($data)) {
            // Find the file.
            if (($tree = $this->getTree($environment, dirname($filename), $commitSha))
                && ($blob = $tree->getBlob(basename($filename)))) {
                $raw = $blob->getRawContent();
            } else {
                $raw = false;
            }
            $data = ['raw' => $raw];
            // Skip caching if the file is bigger than 100 KiB.
            if ($raw === false || strlen($raw) <= 102400) {
                $this->cache->save($cacheKey, $data);
            }
        }

        return $data['raw'];
    }
public function readFile($filename, Environment $environment, $commitSha = null)
    {
        $commitSha = $this->normalizeSha($environment, $commitSha);
        $cacheKey = implode(':', ['raw', $environment->project, $filename, $commitSha]);
        $data = $this->cache->fetch($cacheKey);
        if (!is_array($data)) {
            // Find the file.
            if (($tree = $this->getTree($environment, dirname($filename), $commitSha))
                && ($blob = $tree->getBlob(basename($filename)))) {
                $raw = $blob->getRawContent();
            } else {
                $raw = false;
            }
            $data = ['raw' => $raw];
            // Skip caching if the file is bigger than 100 KiB.
            if ($raw === false || strlen($raw) <= 102400) {
                $this->cache->save($cacheKey, $data);
            }
        }

        return $data['raw'];
    }
public function readFile ( $ filename , Environment $ environment , $ commitSha = null ) { $ commitSha = $ this -> normalizeSha ( $ environment , $ commitSha ) ; $ cacheKey = implode ( ':' , [ 'raw' , $ environment -> project , $ filename , $ commitSha ] ) ; $ data = $ this -> cache -> fetch ( $ cacheKey ) ; if ( ! is_array ( $ data ) ) { // Find the file. if ( ( $ tree = $ this -> getTree ( $ environment , dirname ( $ filename ) , $ commitSha ) ) && ( $ blob = $ tree -> getBlob ( basename ( $ filename ) ) ) ) { $ raw = $ blob -> getRawContent ( ) ; } else { $ raw = false ; } $ data = [ 'raw' => $ raw ] ; // Skip caching if the file is bigger than 100 KiB. if ( $ raw === false || strlen ( $ raw ) <= 102400 ) { $ this -> cache -> save ( $ cacheKey , $ data ) ; } } return $ data [ 'raw' ] ; }
Read a file in the environment, using the Git Data API.

@param string      $filename
@param Environment $environment
@param string|null $commitSha

@throws \RuntimeException on error.

@return string|false
The raw contents of the file, or false if the file is not found.
Read a file in the environment using the Git Data API .