switches builder to make use of plugin factory.

This commit is contained in:
meadsteve 2013-11-17 17:24:47 +00:00
parent e1d8239e8a
commit ebb3b9a3e6

View file

@ -90,6 +90,8 @@ class Builder implements LoggerAwareInterface
*/
public $quiet = false;
protected $pluginFactory;
/**
* Set up the builder.
* @param \PHPCI\Model\Build $build
@ -102,6 +104,7 @@ class Builder implements LoggerAwareInterface
}
$this->build = $build;
$this->store = Store\Factory::getStore('Build');
$this->setupPluginFactory($build);
}
/**
@ -416,6 +419,8 @@ class Builder implements LoggerAwareInterface
$class = ucwords($class);
$class = 'PHPCI\\Plugin\\' . str_replace(' ', '', $class);
$this->pluginFactory->buildPlugin($class, $options);
if (!class_exists($class)) {
$this->logFailure('Plugin does not exist: ' . $plugin, $ex);
return false;
@ -491,4 +496,26 @@ class Builder implements LoggerAwareInterface
{
return $this->logger;
}
private function setupPluginFactory(Build $build)
{
$this->pluginFactory = new Plugin\Util\Factory();
$self = $this;
$this->pluginFactory->registerResource(
function () use($self) {
return $self;
},
null,
'PHPCI\\Builder'
);
$this->pluginFactory->registerResource(
function () use($build) {
return $build;
},
null,
'PHPCI\\Model\Build'
);
}
}