Add code to builder so pluginconfig.php is loaded if found in the root
This commit is contained in:
parent
6d4e49d07b
commit
20d5e5a6b2
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -9,4 +9,5 @@ config.php
|
||||||
.htaccess
|
.htaccess
|
||||||
PHPCI/config.yml
|
PHPCI/config.yml
|
||||||
cache
|
cache
|
||||||
/loggerconfig.php
|
/loggerconfig.php
|
||||||
|
/pluginconfig.php
|
|
@ -14,6 +14,7 @@ use PHPCI\Helper\MailerFactory;
|
||||||
use PHPCI\Model\Build;
|
use PHPCI\Model\Build;
|
||||||
use b8\Store;
|
use b8\Store;
|
||||||
use b8\Config;
|
use b8\Config;
|
||||||
|
use PHPCI\Plugin\Util\Factory;
|
||||||
use Psr\Log\LoggerAwareInterface;
|
use Psr\Log\LoggerAwareInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
@ -114,7 +115,10 @@ class Builder implements LoggerAwareInterface, BuildLogger
|
||||||
}
|
}
|
||||||
$this->build = $build;
|
$this->build = $build;
|
||||||
$this->store = Store\Factory::getStore('Build');
|
$this->store = Store\Factory::getStore('Build');
|
||||||
$this->pluginExecutor = new Plugin\Util\Executor($this->buildPluginFactory($build), $this);
|
|
||||||
|
$pluginFactory = $this->buildPluginFactory($build);
|
||||||
|
$pluginFactory->addConfigFromFile(PHPCI_DIR . "/pluginconfig.php");
|
||||||
|
$this->pluginExecutor = new Plugin\Util\Executor($pluginFactory, $this);
|
||||||
|
|
||||||
$this->commandExecutor = new CommandExecutor($this, PHPCI_DIR, $this->quiet, $this->verbose);
|
$this->commandExecutor = new CommandExecutor($this, PHPCI_DIR, $this->quiet, $this->verbose);
|
||||||
}
|
}
|
||||||
|
@ -394,9 +398,15 @@ class Builder implements LoggerAwareInterface, BuildLogger
|
||||||
return $this->logger;
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a configured instance of the plugin factory.
|
||||||
|
*
|
||||||
|
* @param Build $build
|
||||||
|
* @return Factory
|
||||||
|
*/
|
||||||
private function buildPluginFactory(Build $build)
|
private function buildPluginFactory(Build $build)
|
||||||
{
|
{
|
||||||
$pluginFactory = new Plugin\Util\Factory();
|
$pluginFactory = new Factory();
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$pluginFactory->registerResource(
|
$pluginFactory->registerResource(
|
||||||
|
|
22
pluginconfig.php.example
Normal file
22
pluginconfig.php.example
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
return function (PHPCI\Plugin\Util\Factory $factory) {
|
||||||
|
$factory->registerResource(
|
||||||
|
// This function will be called when the resource is needed.
|
||||||
|
function() {
|
||||||
|
return array(
|
||||||
|
'Foo' => "Stuff",
|
||||||
|
'Bar' => "More Stuff"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
// In addition to the function for building the resource the system
|
||||||
|
// also needs to be told when to load the resource. Either or both
|
||||||
|
// of the following arguments can be used (null to ignore)
|
||||||
|
|
||||||
|
// This resource will only be given when the argument name is:
|
||||||
|
"ResourceArray",
|
||||||
|
|
||||||
|
// The resource will only be given when the type hint is:
|
||||||
|
PHPCI\Plugin\Util\Factory::TYPE_ARRAY
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in a new issue