本文整理汇总了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;
}
示例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());
}
示例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']);
}
示例4: __construct
/**
* @param array $providers
*/
public function __construct(array $providers)
{
$this->container = new PimpleContainer();
foreach ($providers as $provider) {
$this->container->register($provider);
}
}
示例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;
}
示例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');
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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>');
}
示例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