Webiny\Component\Config\ConfigCache::getCache PHP Method

getCache() public static method

Get config from cache
public static getCache ( mixed $resource ) : ConfigObject
$resource mixed
return ConfigObject
    public static function getCache($resource)
    {
        if (!self::isArrayObject(self::$configCache)) {
            self::$configCache = self::arr(self::$configCache);
        }
        $cacheKey = !self::isMd5($resource) ? self::createCacheKey($resource) : $resource;
        if (self::$configCache->keyExists($cacheKey)) {
            return self::$configCache->key($cacheKey);
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * Parse resource and create a Config object
  * A valid resource is a PHP array, ArrayObject or an instance of AbstractDriver
  *
  * @param array|ArrayObject|AbstractDriver $resource   Config resource
  * @param bool                             $flushCache Flush existing cache and load config file
  *
  * @return ConfigObject
  */
 public function parseResource($resource, $flushCache = false)
 {
     $driver = $resource;
     $driverAbstractClassName = '\\Webiny\\Component\\Config\\Drivers\\AbstractDriver';
     if (self::isInstanceOf($resource, $driverAbstractClassName)) {
         $resource = $resource->getResource();
     }
     $cache = ConfigCache::getCache($resource);
     if ($flushCache || !$cache) {
         return new ConfigObject($driver);
     }
     return $cache;
 }