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


PHP Container::register方法代码示例

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


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

示例1: initialize

 /**
  * Initialize the DIC.
  */
 protected function initialize()
 {
     $this->container = new Container();
     $containerProvider = new ContainerProvider($this->disabledMethods, $this->disabledFormats);
     $this->container->register($containerProvider);
     $this->initialized = false;
 }
开发者ID:anthonyhowell,项目名称:distill,代码行数:10,代码来源:Distill.php

示例2: register

 /**
  * @param Container $container A Pimple DI container.
  * @return void
  */
 public function register(Container $container)
 {
     $container->register(new DashboardServiceProvider());
     $container->register(new FormServiceProvider());
     $container->register(new LayoutServiceProvider());
     $container->register(new MenuServiceProvider());
 }
开发者ID:locomotivemtl,项目名称:charcoal-ui,代码行数:11,代码来源:UiServiceProvider.php

示例3: testCreateTemplating

 public function testCreateTemplating()
 {
     $pimple = new Container(['debug' => false, 'charset' => '']);
     $pimple->register(new TwigEngineServiceProvider());
     $pimple->register(new TwigServiceProvider());
     $this->assertInstanceOf(TwigEngine::class, $pimple['templating']);
 }
开发者ID:glaubinix,项目名称:silex-twig-engine,代码行数:7,代码来源:TwigEngineServiceProviderTest.php

示例4: __construct

 /**
  * @param array $providers
  */
 public function __construct(array $providers)
 {
     $this->container = new PimpleContainer();
     foreach ($providers as $provider) {
         $this->container->register($provider);
     }
 }
开发者ID:rjd22,项目名称:kohana-pimple,代码行数:10,代码来源:Container.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * set context inside container
      */
     $this->container->register(new LoggerProvider($output));
     try {
         /** @var LoggerInterface $logger */
         $logger = $this->container['logger'];
         $connection = ['host' => $input->getArgument('host'), 'port' => $input->getArgument('port'), 'user' => $input->getArgument('username'), 'password' => $input->getArgument('password')];
         $client = $this->container['curl_client_factory']->createClient($connection);
         $queueManager = $this->container['manager_rabbitmq_queue'];
         $exchangeManager = $this->container['manager_rabbitmq_exchange'];
         $policygeManager = $this->container['manager_rabbitmq_policy'];
         $manager = new DeleteManager($exchangeManager, $queueManager, $policygeManager, $logger);
         if ($input->hasOption('queues') && null !== $input->getOption('queues')) {
             $queueManager->setClient($client);
             $manager->deleteQueues($input->getOption('vhost'), $input->getOption('queues'));
         }
         if ($input->hasOption('exchanges') && null !== $input->getOption('exchanges')) {
             $exchangeManager->setClient($client);
             $manager->deleteExchanges($input->getOption('vhost'), $input->getOption('exchanges'));
         }
         if ($input->hasOption('policies') && null !== $input->getOption('policies')) {
             $policygeManager->setClient($client);
             $manager->deletePolicies($input->getOption('vhost'), $input->getOption('policies'));
         }
     } catch (\Exception $e) {
         $logger->critical($e->getMessage());
         return 1;
     }
     return 0;
 }
开发者ID:metfan,项目名称:rabbit-setup,代码行数:33,代码来源:DeleteCommand.php

示例6: testDump

 public function testDump()
 {
     $container = new Container();
     $container['debug'] = false;
     $container['charset'] = 'utf-8';
     $logger = $this->getLogger();
     $container['logger'] = $logger;
     $container->register(new TwigServiceProvider());
     $twigPath = $this->getTwigPath();
     $container['twig.loader.filesystem'] = $container->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $twigLoaderFilesystem) use($twigPath) {
         $twigLoaderFilesystem->addPath($twigPath, 'SaxulumAsseticTwig');
         return $twigLoaderFilesystem;
     });
     $container->register(new AsseticTwigProvider(), array('assetic.asset.root' => $this->getFixturesPath(), 'assetic.asset.asset_root' => $this->getAssetPath()));
     /** @var Dumper $dumper */
     $dumper = $container['assetic.asset.dumper'];
     $dumper->dump();
     if (count($logger->entries)) {
         var_dump($logger->entries);
     }
     $this->assertCount(0, $logger->entries);
     $this->fileComparsion('css/test-copyfile.css');
     $this->fileComparsion('image/test.png');
     $this->fileComparsion('css/test-less.css');
     $this->fileComparsion('css/test-scss.css');
     $this->fileComparsion('css/test-cssmin.css');
     $this->fileComparsion('css/test-csscompress.css');
     $this->fileComparsion('js/test.js');
 }
开发者ID:saxulum,项目名称:saxulum-assetic-twig-provider,代码行数:29,代码来源:AsseticTwigProviderTest.php

示例7: shouldReturnTheCommands

 /**
  * @test
  */
 public function shouldReturnTheCommands()
 {
     $app = new Container();
     $app->register(new DoctrineServiceProvider());
     $app->register(new ConsoleServiceProvider());
     $app->register(new DoctrineMigrationsServiceProvider(), ['migrations.options' => ['name' => 'Doctrine Migrations', 'namespace' => 'DoctrineMigrations', 'table_name' => 'doctrine_migration_versions', 'directory' => sys_get_temp_dir()]]);
     $this->assertCount(5, $app['console']->all('migrations'));
 }
开发者ID:sergiors,项目名称:doctrine-migrations-service-provider,代码行数:11,代码来源:DoctrineMigrationsServiceProviderTest.php

示例8: register

 /**
  * Registers a service provider.
  *
  * @param \Pimple\ServiceProviderInterface $provider A ServiceProviderInterface instance
  * @param array                            $values   An array of values that customizes the provider
  * @return \Pimple\Container
  */
 public function register(ServiceProviderInterface $provider, array $values = [])
 {
     $this->container->register($provider, $values);
     // register event subcriber
     if ($provider instanceof EventSubscriberInterface) {
         $this->eventSubscribers[] = $provider;
     }
     return $this;
 }
开发者ID:lemonphp,项目名称:cli,代码行数:16,代码来源:App.php

示例9: getApplication

 /**
  * @return \Pimple\Container
  */
 public static function getApplication()
 {
     if (!self::$application) {
         self::$application = new \Pimple\Container();
         self::$application->register(new Providers\DefaultObjectProvider());
         self::$application->register(new Providers\ApplicationParametersProvider());
     }
     return self::$application;
 }
开发者ID:eriktorsner,项目名称:wp-bootstrap,代码行数:12,代码来源:Bootstrap.php

示例10: compile

 /**
  * Register the ServiceProvider in the container.
  *
  * @return Container
  */
 public function compile()
 {
     if (!$this->compiled) {
         $this->compiled = true;
         $this->container->register(new ServiceProvider(), $this->config);
         $this->container->offsetGet('console')->addCommands($this->commands);
     }
     return $this->container;
 }
开发者ID:jonsa,项目名称:pimple-console,代码行数:14,代码来源:Builder.php

示例11: setUp

 public function setUp()
 {
     $_SERVER['ENV'] = 'test';
     $path = ROOT . '/test/resources/';
     $provider = new ConfigurationProvider();
     $this->container = new Container();
     $this->container['config.driver'] = new IniDriver($path);
     $this->container->register($provider);
 }
开发者ID:assertis,项目名称:config-lib,代码行数:9,代码来源:ConfigurationHelperTest.php

示例12: createApplication

 public function createApplication()
 {
     $app = new Container();
     $app['debug'] = true;
     $app->register(new ValidatorServiceProvider());
     $app->register(new DoctrineServiceProvider(), array('db.options' => array('driver' => 'pdo_sqlite', 'path' => $this->getCacheDir() . '/app.db')));
     $app->register(new DoctrineOrmServiceProvider(), array('orm.proxies_dir' => $this->getCacheDir() . '/doctrine/proxies', 'orm.em.options' => array('mappings' => array(array('type' => 'annotation', 'namespace' => 'Saxulum\\Tests\\DoctrineOrmManagerRegistry\\Entity', 'path' => __DIR__ . '/../Entity', 'use_simple_annotation_reader' => false)))));
     $app->register(new DoctrineOrmManagerRegistryProvider());
     return $app;
 }
开发者ID:transmitsms,项目名称:saxulum-doctrine-orm-manager-registry-provider,代码行数:10,代码来源:DoctrineOrmManagerRegistryProviderTest.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * set context inside container
      */
     $this->container->register(new LoggerProvider($output));
     $parser = new ParseExpertConfig();
     $parser->parse($input->getArgument('configFile'));
     $this->container['logger']->info('<info>File don\'t show errors.</info>');
 }
开发者ID:metfan,项目名称:rabbit-setup,代码行数:10,代码来源:ValidateExpertCommand.php

示例14: getContainer

 public function getContainer()
 {
     $container = new Container();
     $container['debug'] = true;
     $container->register(new ValidatorServiceProvider());
     $container->register(new DoctrineMongoDbProvider(), array('mongodb.options' => array('server' => 'mongodb://localhost:27017')));
     $container->register(new DoctrineMongoDbOdmProvider(), array("mongodbodm.proxies_dir" => $this->getCacheDir() . '/doctrine/proxies', "mongodbodm.hydrator_dir" => $this->getCacheDir() . '/doctrine/hydrator', 'mongodbodm.dm.options' => array('mappings' => array(array('type' => 'annotation', 'namespace' => 'Saxulum\\Tests\\DoctrineMongodbOdmManagerRegistry\\Document', 'path' => __DIR__ . '/../Document', 'use_simple_annotation_reader' => false)))));
     $container->register(new DoctrineMongodbOdmManagerRegistryProvider());
     return $container;
 }
开发者ID:saxulum,项目名称:saxulum-doctrine-mongodb-odm-manager-registry-provider,代码行数:10,代码来源:DoctrineMongodbOdmManagerRegistryProviderTest.php

示例15: register

 /**
  * @test
  */
 public function register()
 {
     $app = new Container();
     $app->register(new ValidatorServiceProvider());
     $app->register(new DoctrineServiceProvider());
     $app->register(new DoctrineCacheServiceProvider());
     $app->register(new DoctrineOrmServiceProvider());
     $app->register(new DoctrineManagerRegistryServiceProvider());
     $this->assertArrayHasKey('doctrine', $app);
 }
开发者ID:sergiors,项目名称:doctrine-manager-registry-service-provider,代码行数:13,代码来源:DoctrineManagerServiceProviderTest.php


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