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


PHP Container::has方法代码示例

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


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

示例1: testExists

 /**
  * @testdox The existence of a resource can be checked
  */
 public function testExists()
 {
     $container = new Container();
     $container->set('foo', 'bar');
     $this->assertTrue($container->has('foo'), "'foo' should be present");
     $this->assertFalse($container->has('baz'), "'baz' should not be present");
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:10,代码来源:ContainerAccessTest.php

示例2: testExistsResolvesAlias

 /**
  * @testdox has() also resolves the alias if set.
  */
 public function testExistsResolvesAlias()
 {
     $container = new Container();
     $container->set('foo', function () {
         return new \stdClass();
     }, true, true)->alias('bar', 'foo');
     $this->assertTrue($container->has('foo'), "Original 'foo' was not resolved");
     $this->assertTrue($container->has('bar'), "Alias 'bar' was not resolved");
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:12,代码来源:AliasingTest.php

示例3: createCommandBus

 /**
  * @param   Container  $container  The container
  *
  * @return  \Joomla\Service\CommandBus
  */
 public function createCommandBus(Container $container)
 {
     // Construct the command handler middleware
     $middleware = [];
     if ($container->has('CommandBusMiddleware')) {
         $middleware = (array) $container->get('CommandBusMiddleware');
     }
     if ($container->has('extension_factory')) {
         $middleware[] = new ExtensionQueryMiddleware($container->get('extension_factory'));
     }
     $builder = new CommandBusBuilder($container->get('EventDispatcher'));
     $middleware = array_merge($middleware, $builder->getMiddleware());
     $builder->setMiddleware($middleware);
     return $builder->getCommandBus();
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:20,代码来源:CommandBusServiceProvider.php

示例4: testDecorateArbitraryInteropContainerAlias

 /**
  * @testdox Container can manage an alias for a resource from an arbitrary Interop compatible container
  */
 public function testDecorateArbitraryInteropContainerAlias()
 {
     $container = new Container(new \ArbitraryInteropContainer());
     $container->alias('foo', 'aic_foo');
     $this->assertTrue($container->has('foo'), "Container does not know alias 'foo'");
     $this->assertEquals('aic_foo_content', $container->get('foo'), "Container does not return the correct value for alias 'foo'");
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:10,代码来源:HierachicalTest.php

示例5: register

 /**
  * Add the configuration from the environment to a container
  *
  * @param   Container $container The container
  * @param   string    $alias     An optional alias, defaults to 'config'
  *
  * @return  void
  */
 public function register(Container $container, $alias = 'config')
 {
     $file = '.env';
     if ($container->has('ConfigFileName')) {
         $file = $container->get('ConfigFileName');
     }
     $dotenv = new Dotenv($container->get('ConfigDirectory'), $file);
     $dotenv->overload();
     $container->set($alias, new Registry($_ENV), true);
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:18,代码来源:ConfigServiceProvider.php

示例6: testLoadWithInvalidClass

    /**
     * @testdox Loading an invalid class
     */
    public function testLoadWithInvalidClass()
    {
        $content = <<<EOF
[providers]
foo = "\\NotAvailableServiceProvider"
EOF;
        $container = new Container();
        $loader = new IniLoader($container);
        $loader->load($content);
        $this->assertFalse($container->has('foo'));
    }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:14,代码来源:IniLoaderTest.php

示例7: createRepositoryFactory

 /**
  * Creates a RepositoryFactory
  *
  * @param   Container $container The container
  *
  * @return  RepositoryFactory
  */
 public function createRepositoryFactory(Container $container)
 {
     $config = parse_ini_file(JPATH_ROOT . '/config/database.ini', true);
     $configuration = new Configuration();
     // Add logger
     $logger = new DebugStack();
     $configuration->setSQLLogger($logger);
     $connection = DriverManager::getConnection(['url' => $config['databaseUrl']], $configuration);
     $transactor = new DoctrineTransactor($connection);
     $repositoryFactory = new RepositoryFactory($config, $connection, $transactor);
     if ($container->has('dispatcher')) {
         $repositoryFactory->setDispatcher($container->get('dispatcher'));
     }
     return $repositoryFactory;
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:22,代码来源:StorageServiceProvider.php


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