当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::registerServiceProvider方法代码示例

本文整理汇总了PHP中Joomla\DI\Container::registerServiceProvider方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::registerServiceProvider方法的具体用法?PHP Container::registerServiceProvider怎么用?PHP Container::registerServiceProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Joomla\DI\Container的用法示例。


在下文中一共展示了Container::registerServiceProvider方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $this->dataDirectory = __DIR__ . '/tmp';
     $this->mkdir($this->dataDirectory . '/entities');
     $container = new Container();
     $container->set('ConfigDirectory', JPATH_ROOT);
     $container->registerServiceProvider(new StorageServiceProvider(), 'repository');
     $container->registerServiceProvider(new EventDispatcherServiceProvider(), 'dispatcher');
     $container->registerServiceProvider(new ExtensionFactoryServiceProvider(), 'extension_factory');
     $this->installer = new Installer($this->dataDirectory, $container);
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:11,代码来源:InstallerTest.php

示例2: RendererAddsTheEventDecorator

 public function RendererAddsTheEventDecorator(UnitTester $I)
 {
     $container = new Container();
     $container->set('ConfigDirectory', JPATH_ROOT);
     $container->registerServiceProvider(new StorageServiceProvider(), 'repository');
     $container->registerServiceProvider(new EventDispatcherServiceProvider(), 'dispatcher');
     $container->registerServiceProvider(new ExtensionFactoryServiceProvider(), 'extension_factory');
     $app = new Application([new RendererMiddleware(new Dispatcher(), $container), function (ServerRequestInterface $request, ResponseInterface $response, callable $next) use($I) {
         $body = $response->getBody();
         $I->assertEquals(EventDecorator::class, get_class($body));
         return $next($request, $response);
     }]);
     $app->run(new ServerRequest());
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:14,代码来源:RendererCest.php

示例3: init

 /**
  * Init this component.
  *
  * @return void
  */
 public function init()
 {
     $dispatcher = $this->container->get('event.dispatcher');
     // Event
     $dispatcher->trigger('onComponentBeforeInit', array($this->name, $this, $this->input));
     // We build component path constant, helpe us get path easily.
     $this->path['self'] = JPATH_BASE . '/components/' . strtolower($this->option);
     $this->path['site'] = JPATH_ROOT . '/components/' . strtolower($this->option);
     $this->path['administrator'] = JPATH_ROOT . '/administrator/components/' . strtolower($this->option);
     define(strtoupper($this->name) . '_SELF', $this->path['self']);
     define(strtoupper($this->name) . '_SITE', $this->path['site']);
     define(strtoupper($this->name) . '_ADMIN', $this->path['administrator']);
     // Register some useful object for this component.
     $this->container->registerServiceProvider(new ComponentProvider($this->name, $this));
     $task = $this->input->getWord('task');
     $controller = $this->input->getWord('controller');
     // Prepare default controller
     if (!$task && !$controller) {
         // If we got view, set it to display controller.
         $view = $this->input->get('view');
         $task = $view ? $view . '.display' : $this->defaultController;
         $this->input->set('task', $task);
         $this->input->set('controller', $task);
     }
     // Register form and fields
     \JForm::addFieldPath(WINDWALKER_SOURCE . '/Form/Fields');
     \JForm::addFormPath(WINDWALKER_SOURCE . '/Form/Forms');
     $this->registerEventListener();
     // Register elFinder controllers
     // @TODO: Should use event listener
     $this->registerTask('finder.elfinder.display', '\\Windwalker\\Elfinder\\Controller\\DisplayController');
     $this->registerTask('finder.elfinder.connect', '\\Windwalker\\Elfinder\\Controller\\ConnectController');
     // Event
     $dispatcher->trigger('onComponentAfterInit', array($this->name, $this, $this->input));
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:40,代码来源:Component.php

示例4: testRegisterServiceProvider

 /**
  * Test registering a service provider. Make sure register get's called.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testRegisterServiceProvider()
 {
     $mock = $this->getMock('Joomla\\DI\\ServiceProviderInterface');
     $mock->expects($this->once())->method('register');
     $returned = $this->fixture->registerServiceProvider($mock);
     $this->assertSame($returned, $this->fixture, 'When registering a service provider, the container instance should be returned.');
 }
开发者ID:ZerGabriel,项目名称:joomla-framework,代码行数:14,代码来源:ContainerTest.php

示例5: __construct

 /**
  * Instantiate the controller.
  *
  * @param   \Joomla\DI\Container $container  DI Container.
  * @param   IOInterface          $io         The Controller object.
  */
 public function __construct(JoomlaContainer $container = null, IOInterface $io = null)
 {
     $this->container = $container ?: $this->getContainer();
     // Set provider
     $container->registerServiceProvider(new ServiceProvider());
     parent::__construct($io);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:13,代码来源:GeneratorController.php

示例6: testTheCommandBusHasAnExecuteMethodThatTakesAQueryAsAParameter

 /**
  * @testdox The modified command bus has an execute method that takes a Query as a parameter
  */
 public function testTheCommandBusHasAnExecuteMethodThatTakesAQueryAsAParameter()
 {
     $this->expectOutputString(sprintf("LOG: Starting %1\$s\nLOG: Ending %1\$s\n", "Joomla\\Tests\\Unit\\Service\\Stubs\\SimpleQuery"));
     $container = new Container();
     $container->set('EventDispatcher', $this->getMockBuilder(DispatcherInterface::class)->getMock());
     $container->set('CommandBusMiddleware', [new LoggingMiddleware(new Logger())]);
     $container->registerServiceProvider(new CommandBusServiceProvider());
     $commandBus = $container->get('CommandBus');
     $this->assertEquals('XSome contentY', $commandBus->handle(new SimpleQuery('Some content')));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:13,代码来源:CommandBusServiceProviderTest.php

示例7: initialise

 /**
  * Custom initialisation method.
  *
  * Called at the end of the Base::__construct method. This is for developers to inject initialisation code for their application classes.
  *
  * @return  void
  *
  * @codeCoverageIgnore
  * @since   1.0
  */
 protected function initialise()
 {
     // New DI stuff!
     $container = new Container();
     $input = $this->input;
     $container->share('input', function (Container $c) use($input) {
         return $input;
     }, true);
     $container->registerServiceProvider(new Providers\ConfigServiceProvider(TAGALISER_CONFIG));
     $container->registerServiceProvider(new Providers\GithubServiceProvider());
     $container->registerServiceProvider(new Providers\LoggerServiceProvider());
     $container->registerServiceProvider(new Providers\MustacheServiceProvider());
     $this->container = $container;
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:24,代码来源:Application.php

示例8: testTheDatabaseServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The database service provider is registered to the DI container
  *
  * @covers  Stats\Providers\DatabaseServiceProvider::register
  */
 public function testTheDatabaseServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new DatabaseServiceProvider());
     $this->assertTrue($container->exists('Joomla\\Database\\DatabaseDriver'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:11,代码来源:DatabaseServiceProviderTest.php

示例9: testTheApplicationServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The application service provider is registered to the DI container
  *
  * @covers  Stats\Providers\ApplicationServiceProvider::register
  */
 public function testTheApplicationServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new ApplicationServiceProvider());
     $this->assertTrue($container->exists('Stats\\Application'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:11,代码来源:ApplicationServiceProviderTest.php

示例10: testTheConfigServiceProviderIsRegisteredToTheContainer

 /**
  * @testdox The config service provider is registered to the DI container
  *
  * @covers  Stats\Providers\ConfigServiceProvider::__construct
  * @covers  Stats\Providers\ConfigServiceProvider::register
  */
 public function testTheConfigServiceProviderIsRegisteredToTheContainer()
 {
     $container = new Container();
     $container->registerServiceProvider(new ConfigServiceProvider(APPROOT . '/etc/config.dist.json'));
     $this->assertTrue($container->exists('config'));
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:12,代码来源:ConfigServiceProviderTest.php


注:本文中的Joomla\DI\Container::registerServiceProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。