/**
* 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;
}