Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Validation] Checks if the provided array configuration is cache-able #1

Open
gabbydgab opened this issue Jan 10, 2017 · 0 comments
Open

Comments

@gabbydgab
Copy link
Contributor

gabbydgab commented Jan 10, 2017

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant