register() public method

{@inheritDoc}
public register ( Pimple\ServiceProviderInterface $provider, array $values = [] )
$provider Pimple\ServiceProviderInterface
$values array
Ejemplo n.º 1
0
 /**
  * Tests whether the register method applies the provided parameters to this
  * application and correctly registers the ServiceProvider.
  */
 public function testRegister()
 {
     $provider = new ServiceProviderMock();
     $this->fixture->register($provider, array('mock.param' => true));
     $this->assertTrue($this->fixture['mock.param']);
     $this->assertSame($this->fixture['mock'], $provider);
 }
Ejemplo n.º 2
0
 /**
  * Test that register will throw an exception if an unknown
  * format is passed in
  *
  * @return void
  */
 public function testRegisterThrowsExceptionIfAnUnknownFormatIsPassed()
 {
     $this->setExpectedException('InvalidArgumentException', 'Unable to load configuration; the provided file extension was not recognized. Only yml or xml allowed');
     $app = new Application('Test');
     $app->register(new ConfigServiceProvider(), array('config.path' => __DIR__ . '/../../../data/config.unknownfiletype'));
     $config = $app['config'];
 }
Ejemplo n.º 3
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance.
  */
 public function register(Application $app)
 {
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     /** @var Collection $writerCollection */
     $writerCollection = $app['transformer.writer.collection'];
     $writerCollection['FileIo'] = new Writer\FileIo();
     $writerCollection['checkstyle'] = new Writer\Checkstyle();
     $writerCollection['sourcecode'] = new Writer\Sourcecode();
     $writerCollection['statistics'] = new Writer\Statistics();
     $writerCollection['xml'] = new Writer\Xml($app['transformer.routing.standard']);
     $writerCollection['xsl'] = new Writer\Xsl($app['monolog']);
     $writerCollection['checkstyle']->setTranslator($translator);
     $writerCollection['xml']->setTranslator($translator);
     Xslt\Extension::$routers = $app['transformer.routing.queue'];
     Xslt\Extension::$descriptorBuilder = $app['descriptor.builder'];
     $app->register(new \phpDocumentor\Plugin\Graphs\ServiceProvider());
     $app->register(new \phpDocumentor\Plugin\Twig\ServiceProvider());
     $app->register(new \phpDocumentor\Plugin\Pdf\ServiceProvider());
 }
Ejemplo n.º 4
0
 public function register(Application $app)
 {
     /** @var ApplicationConfiguration $config */
     $config = $app['config'];
     $plugins = $config->getPlugins();
     if (!$plugins) {
         $app->register(new Core\ServiceProvider());
         $app->register(new Scrybe\ServiceProvider());
         return;
     }
     array_walk($plugins, function ($plugin) use($app) {
         /** @var Plugin $plugin */
         $provider = strpos($plugin->getClassName(), '\\') === false ? sprintf('phpDocumentor\\Plugin\\%s\\ServiceProvider', $plugin->getClassName()) : $plugin->getClassName();
         if (!class_exists($provider)) {
             throw new \RuntimeException('Loading Service Provider for ' . $provider . ' failed.');
         }
         try {
             $app->register(new $provider($plugin));
         } catch (\InvalidArgumentException $e) {
             throw new \RuntimeException($e->getMessage());
         }
     });
 }
 public function testRegister()
 {
     $app = new Application('Test');
     $app->register(new ValidatorServiceProvider(), array('validator.class_path' => __DIR__ . '/../../../../vendor/Symfony/Component/Validator'));
     return $app;
 }