Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Expose formally protected method in ConfigListener #2390

Closed
wants to merge 1 commit into from

2 participants

@prolic

I made the "hasCachedConfig()" method public and added it to ConfigMergerInterface.
The reason for this is, sometimes it's useful to know, whether or not the config object is already merged and cached or not.
F.e. when I allow a method like: "getPHPUnitPaths()" in a module with an PHPUnitProviderInterface, and the return value should get merged into the config file this would lead to bugs, because the order of the modules is not correctly applied any more. Therefore I need to know, whether the work is already done and therefore I know, I can skip at this point. Otherwise I can merge together a part of config file from "getConfig()" with the return value of a custom provider method.

@prolic prolic Expose formally protected method in ConfigListener
I made the "hasCachedConfig()" method public and added it to ConfigMergerInterface.
The reason for this is, sometimes it's useful to know, whether or not the config object is already merged and cached or not.
F.e. when I allow a method like: "getPHPUnitPaths()" in a module with an PHPUnitProviderInterface, and the return value should get merged into the config file this would lead to bugs, because the order of the modules is not correctly applied any more. Therefore I need to know, whether the work is already done and therefore I know, I can skip at this point. Otherwise it will merge together a part of config file from "getConfig()" with the return value of a custom provider method.
5d7e5a4
@weierophinney

Changing interfaces is a no-no, as it breaks backwards compatibility. Create a new interface with that method, and in userland code, developers can test against that interface before calling hasCachedConfig().

@prolic

Okay, will work on this tomorrow.

@prolic

After thinking about this a little longer, I think now the whole point was a bad idea. Closing now.

@prolic prolic closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 19, 2012
  1. @prolic

    Expose formally protected method in ConfigListener

    prolic authored
    I made the "hasCachedConfig()" method public and added it to ConfigMergerInterface.
    The reason for this is, sometimes it's useful to know, whether or not the config object is already merged and cached or not.
    F.e. when I allow a method like: "getPHPUnitPaths()" in a module with an PHPUnitProviderInterface, and the return value should get merged into the config file this would lead to bugs, because the order of the modules is not correctly applied any more. Therefore I need to know, whether the work is already done and therefore I know, I can skip at this point. Otherwise it will merge together a part of config file from "getConfig()" with the return value of a custom provider method.
This page is out of date. Refresh to see the latest.
View
28 library/Zend/ModuleManager/Listener/ConfigListener.php
@@ -278,6 +278,21 @@ public function addConfigStaticPath($staticPath)
}
/**
+ * Whether the config is already cached
+ *
+ * @return bool
+ */
+ public function hasCachedConfig()
+ {
+ if (($this->getOptions()->getConfigCacheEnabled())
+ && (file_exists($this->getOptions()->getConfigCacheFile()))
+ ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Add an array of paths of config files to merge after loading modules
*
* @param Traversable|array $paths
@@ -374,19 +389,6 @@ protected function addConfigByPath($path, $type)
}
/**
- * @return bool
- */
- protected function hasCachedConfig()
- {
- if (($this->getOptions()->getConfigCacheEnabled())
- && (file_exists($this->getOptions()->getConfigCacheFile()))
- ) {
- return true;
- }
- return false;
- }
-
- /**
* @return mixed
*/
protected function getCachedConfig()
View
7 library/Zend/ModuleManager/Listener/ConfigMergerInterface.php
@@ -34,4 +34,11 @@ public function getMergedConfig($returnConfigAsObject = true);
* @return ConfigMergerInterface
*/
public function setMergedConfig(array $config);
+
+ /**
+ * Whether the config is already cached
+ *
+ * @return bool
+ */
+ public function hasCachedConfig();
}
Something went wrong with that request. Please try again.