Ability to check if the array configuration is cache-able or not. Will return false if the configuration is mapped to a closure.
$config = [
'dependencies' => [
'factories' => [
'closure-factory' => function () { return new \stdClass() }
]
]
];
// backwards compatible
ArrayUtils::isCacheable($config); // returns false
// using validator class
ArrayValidator::isCacheable($config); // returns false
Checking all loaded configuration:
It will reduce the following merge configuration logic in Zend\ConfigAggregator
Practical usage
private function cacheConfig(array $config, $cachedConfigFile)
{
if (!ArrayValidator::isCacheable($config)) {
throw new InvalidArgumentException('Cannot cached config from %s; does not return array', $config);
}
// cache the config
}