src/helpers/Manifest.php
protected static function getFileContents(string $path, callable $callback = null)
    {
        // Return the memoized manifest if it exists
        if (!empty(self::$files[$path])) {
            return self::$files[$path];
        }
        // Create the dependency tags
        $dependency = new TagDependency([
            'tags' => [
                self::CACHE_TAG,
                self::CACHE_TAG.$path,
            ],
        ]);
        // Set the cache duration based on devMode
        $cacheDuration = Craft::$app->getConfig()->getGeneral()->devMode
            ? self::DEVMODE_CACHE_DURATION
            : null;
        // Get the result from the cache, or parse the file
        $cache = Craft::$app->getCache();
        $file = $cache->getOrSet(
            self::CACHE_KEY.$path,
            function () use ($path, $callback) {
                $result = null;
                if (UrlHelper::isAbsoluteUrl($path)) {
                    /**
                     * Silly work-around for what appears to be a file_get_contents bug with https
                     * http://stackoverflow.com/questions/10524748/why-im-getting-500-error-when-using-file-get-contents-but-works-in-a-browser
                     */
                    $opts = [
                        'ssl' => [
                            'verify_peer' => false,
                            'verify_peer_name' => false,
                        ],
                        'http' => [
                            'ignore_errors' => true,
                            'header' => "User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13\r\n",
                        ],
                    ];
                    $context = stream_context_create($opts);
                    $contents = @file_get_contents($path, false, $context);
                } else {
                    $contents = @file_get_contents($path);
                }
                if ($contents) {
                    $result = $contents;
                    if ($callback) {
                        $result = $callback($result);
                    }
                }

                return $result;
            },
            $cacheDuration,
            $dependency
        );
        self::$files[$path] = $file;

        return $file;
    }
protected static function getFileContents(string $path, callable $callback = null)
    {
        // Return the memoized manifest if it exists
        if (!empty(self::$files[$path])) {
            return self::$files[$path];
        }
        // Create the dependency tags
        $dependency = new TagDependency([
            'tags' => [
                self::CACHE_TAG,
                self::CACHE_TAG.$path,
            ],
        ]);
        // Set the cache duration based on devMode
        $cacheDuration = Craft::$app->getConfig()->getGeneral()->devMode
            ? self::DEVMODE_CACHE_DURATION
            : null;
        // Get the result from the cache, or parse the file
        $cache = Craft::$app->getCache();
        $file = $cache->getOrSet(
            self::CACHE_KEY.$path,
            function () use ($path, $callback) {
                $result = null;
                if (UrlHelper::isAbsoluteUrl($path)) {
                    /**
                     * Silly work-around for what appears to be a file_get_contents bug with https
                     * http://stackoverflow.com/questions/10524748/why-im-getting-500-error-when-using-file-get-contents-but-works-in-a-browser
                     */
                    $opts = [
                        'ssl' => [
                            'verify_peer' => false,
                            'verify_peer_name' => false,
                        ],
                        'http' => [
                            'ignore_errors' => true,
                            'header' => "User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13\r\n",
                        ],
                    ];
                    $context = stream_context_create($opts);
                    $contents = @file_get_contents($path, false, $context);
                } else {
                    $contents = @file_get_contents($path);
                }
                if ($contents) {
                    $result = $contents;
                    if ($callback) {
                        $result = $callback($result);
                    }
                }

                return $result;
            },
            $cacheDuration,
            $dependency
        );
        self::$files[$path] = $file;

        return $file;
    }
protected static function getFileContents ( string $ path , callable $ callback = null ) { // Return the memoized manifest if it exists if ( ! empty ( self :: $ files [ $ path ] ) ) { return self :: $ files [ $ path ] ; } // Create the dependency tags $ dependency = new TagDependency ( [ 'tags' => [ self :: CACHE_TAG , self :: CACHE_TAG . $ path , ] , ] ) ; // Set the cache duration based on devMode $ cacheDuration = Craft :: $ app -> getConfig ( ) -> getGeneral ( ) -> devMode ? self :: DEVMODE_CACHE_DURATION : null ; // Get the result from the cache, or parse the file $ cache = Craft :: $ app -> getCache ( ) ; $ file = $ cache -> getOrSet ( self :: CACHE_KEY . $ path , function ( ) use ( $ path , $ callback ) { $ result = null ; if ( UrlHelper :: isAbsoluteUrl ( $ path ) ) { /**
                     * Silly work-around for what appears to be a file_get_contents bug with https
                     * http://stackoverflow.com/questions/10524748/why-im-getting-500-error-when-using-file-get-contents-but-works-in-a-browser
                     */ $ opts = [ 'ssl' => [ 'verify_peer' => false , 'verify_peer_name' => false , ] , 'http' => [ 'ignore_errors' => true , 'header' => "User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13\r\n" , ] , ] ; $ context = stream_context_create ( $ opts ) ; $ contents = @ file_get_contents ( $ path , false , $ context ) ; } else { $ contents = @ file_get_contents ( $ path ) ; } if ( $ contents ) { $ result = $ contents ; if ( $ callback ) { $ result = $ callback ( $ result ) ; } } return $ result ; } , $ cacheDuration , $ dependency ) ; self :: $ files [ $ path ] = $ file ; return $ file ; }
Return the contents of a file from the passed in path

@param string   $path
@param callable $callback

@return null|mixed
Return the contents of a file from the passed in path