當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。