コード例 #1
0
ファイル: Executor.php プロジェクト: stefanius/phpci-box
 /**
  * Executes a given plugin, with options and returns the result.
  */
 public function executePlugin($plugin, $options)
 {
     // Any plugin name without a namespace separator is a PHPCI built in plugin
     // if not we assume it's a fully name-spaced class name that implements the plugin interface.
     // If not the factory will throw an exception.
     if (strpos($plugin, '\\') === false) {
         $class = str_replace('_', ' ', $plugin);
         $class = ucwords($class);
         $class = 'PHPCI\\Plugin\\' . str_replace(' ', '', $class);
     } else {
         $class = $plugin;
     }
     if (!class_exists($class)) {
         $this->logger->logFailure(Lang::get('plugin_missing', $plugin));
         return false;
     }
     $rtn = true;
     // Try running it:
     try {
         $obj = $this->pluginFactory->buildPlugin($class, $options);
         if (!$obj->execute()) {
             $rtn = false;
         }
     } catch (\Exception $ex) {
         $this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
         $rtn = false;
     }
     return $rtn;
 }
コード例 #2
0
ファイル: FactoryTest.php プロジェクト: mrudtf/PHPCI
 /**
  * Registers mocked Builder and Build classes so that realistic plugins
  * can be tested.
  */
 private function registerBuildAndBuilder()
 {
     $this->testedFactory->registerResource(function () {
         return $this->getMock('PHPCI\\Builder', array(), array(), '', false);
     }, null, 'PHPCI\\Builder');
     $this->testedFactory->registerResource(function () {
         return $this->getMock('PHPCI\\Model\\Build', array(), array(), '', false);
     }, null, 'PHPCI\\Model\\Build');
 }
コード例 #3
0
ファイル: Builder.php プロジェクト: bdanchilla/PHPCI
 /**
  * Returns a configured instance of the plugin factory.
  *
  * @param Build $build
  * @return PluginFactory
  */
 private function buildPluginFactory(Build $build)
 {
     $pluginFactory = new PluginFactory();
     $self = $this;
     $pluginFactory->registerResource(function () use($self) {
         return $self;
     }, null, 'PHPCI\\Builder');
     $pluginFactory->registerResource(function () use($build) {
         return $build;
     }, null, 'PHPCI\\Model\\Build');
     $logger = $this->logger;
     $pluginFactory->registerResource(function () use($logger) {
         return $logger;
     }, null, 'Psr\\Log\\LoggerInterface');
     $pluginFactory->registerResource(function () use($self) {
         $factory = new MailerFactory($self->getSystemConfig('phpci'));
         return $factory->getSwiftMailerFromConfig();
     }, null, 'Swift_Mailer');
     return $pluginFactory;
 }
コード例 #4
0
ファイル: Executor.php プロジェクト: ntoniazzi/PHPCI
 /**
  * Sets the summary data of the current build.
  *
  * @param array summary
  */
 private function setBuildSummary($summary)
 {
     $build = $this->pluginFactory->getResourceFor('PHPCI\\Model\\Build');
     $this->store->setMeta($build->getProjectId(), $build->getId(), 'plugin-summary', json_encode($summary));
 }