From 7e669ada4797fcce9e7e5c1d21e1bbcd3ad11db2 Mon Sep 17 00:00:00 2001 From: "steve.brazier" Date: Tue, 25 Mar 2014 14:17:03 +0000 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into feature/pluginfactoryconfig Conflicts: PHPCI/Builder.php PHPCI/Plugin/Util/Factory.php --- PHPCI/Plugin/Util/Factory.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/PHPCI/Plugin/Util/Factory.php b/PHPCI/Plugin/Util/Factory.php index 9740516f..097f8bf5 100644 --- a/PHPCI/Plugin/Util/Factory.php +++ b/PHPCI/Plugin/Util/Factory.php @@ -36,7 +36,28 @@ class Factory { 'array' ); } - + + /** + * Trys to get a function from the file path specified. If the + * file returns a function then $this will be passed to it. + * This enables the config file to call any public methods. + * + * @param $configPath + * @return bool - true if the function exists else false. + */ + public function addConfigFromFile($configPath) + { + // The file is expected to return a function which can + // act on the pluginFactory to register any resources needed. + if (file_exists($configPath)) { + $configFunction = require($configPath); + if (is_callable($configFunction)) { + $configFunction($this); + return true; + } + } + return false; + } public function getLastOptions() {