• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DI\Container类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: register

 /**
  * Registers the service provider within a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   2.0
  */
 public function register(Container $container)
 {
     $that = $this;
     $container->set('mustache', function ($c) use($that) {
         return $that->getMustache($c);
     });
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:16,代码来源:MustacheServiceProvider.php


示例2: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  */
 public function register(Container $container)
 {
     $model = $this->model;
     // QueryHelper
     $container->share('model.' . $this->name . '.helper.query', function ($container) use($model) {
         if ($model instanceof ListModel) {
             return $model->getQueryHelper();
         } else {
             return new QueryHelper();
         }
     });
     // Filter
     $container->share('model.' . $this->name . '.filter', function ($container) use($model) {
         if ($model instanceof ListModel) {
             return $model->getFilterHelper();
         } else {
             return new FilterHelper();
         }
     })->alias('model.' . $this->name . '.helper.filter', 'model.' . $this->name . '.filter');
     // Search
     $container->share('model.' . $this->name . '.search', function ($container) use($model) {
         if ($model instanceof ListModel) {
             return $model->getSearchHelper();
         } else {
             return new SearchHelper();
         }
     })->alias('model.' . $this->name . '.helper.search', 'model.' . $this->name . '.search');
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:35,代码来源:GridProvider.php


示例3: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $app = $this->app;
     $container->set('app', function () use($app) {
         return $app;
     }, true, true);
 }
开发者ID:houzhenggang,项目名称:cobalt,代码行数:16,代码来源:ApplicationServiceProvider.php


示例4: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  */
 public function register(Container $container)
 {
     // Global Config
     $container->share('joomla.config', array('JFactory', 'getConfig'));
     // Windwalker Config
     $container->share('windwalker.config', array($this, 'loadConfig'));
     // Database
     $this->share($container, 'db', 'JDatabaseDriver', array('JFactory', 'getDbo'));
     // Language
     $this->share($container, 'language', 'JLanguage', array('JFactory', 'getLanguage'));
     // Dispatcher
     $this->share($container, 'event.dispatcher', 'JEventDispatcher', array('JEventDispatcher', 'getInstance'));
     // Date
     $this->set($container, 'date', 'JDate', function () {
         return DateHelper::getDate();
     });
     // Global
     $container->set('SplPriorityQueue', function () {
         return new \SplPriorityQueue();
     });
     // Asset
     $container->share('helper.asset', function () {
         return new \Windwalker\Helper\AssetHelper();
     });
     // Detect deferent environment
     if (defined('WINDWALKER_CONSOLE')) {
         $container->registerServiceProvider(new CliProvider());
     } else {
         $container->registerServiceProvider(new WebProvider());
     }
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:38,代码来源:SystemProvider.php


示例5: register

 /**
  * Registers the service provider within a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.2
  */
 public function register(Container $container)
 {
     $that = $this;
     $container->share('logger', function (Container $c) use($that) {
         return $that->getLogger($c);
     }, true);
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:16,代码来源:LoggerServiceProvider.php


示例6: register

 /**
  * Registers the service provider within a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.2
  */
 public function register(Container $container)
 {
     $that = $this;
     $container->share('config', function ($c) use($that) {
         return $that->getConfig($c);
     }, true);
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:16,代码来源:ConfigServiceProvider.php


示例7: __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


示例8: register

 /**
  * {@inheritdoc}
  */
 public function register(Container $container)
 {
     $config = $this->config;
     $container->share('config', function () use($config) {
         return $config;
     });
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-jfw,代码行数:10,代码来源:ConfigServiceProvider.php


示例9: register

 /**
  * Registers the service provider within a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.1
  */
 public function register(Container $container)
 {
     $that = $this;
     $container->share('github', function (Container $c) use($that) {
         return $that->getGithub($c);
     }, true);
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:16,代码来源:GithubServiceProvider.php


示例10: register

 /**
  * @param   Container $container The DI container
  * @param   string    $alias     An optional alias
  *
  * @return  void
  */
 public function register(Container $container, $alias = null)
 {
     $container->set('Request', [$this, 'createRequest'], true, true);
     if ($alias) {
         $container->alias($alias, 'Request');
     }
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:13,代码来源:RequestServiceProvider.php


示例11: register

 public function register(Container $container)
 {
     $container->alias("db", "Joomla\\Database\\DatabaseDriver")->share("Joomla\\Database\\DatabaseDriver", function () use($container) {
         $config = $container->get("config");
         return DatabaseDriver::getInstance((array) $config["database"]);
     }, true);
 }
开发者ID:roland-d,项目名称:jstats-server,代码行数:7,代码来源:DatabaseServiceProvider.php


示例12: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $container->alias('db', 'Joomla\\Database\\DatabaseDriver')->share('Joomla\\Database\\DatabaseDriver', function (Container $container) {
         $config = $container->get('config');
         return DatabaseDriver::getInstance((array) $config['database']);
     }, true);
 }
开发者ID:alikon,项目名称:jstats-server,代码行数:16,代码来源:DatabaseServiceProvider.php


示例13: testLoadFile

 /**
  * @testdox Loading a file
  */
 public function testLoadFile()
 {
     $container = new Container();
     $loader = new YamlLoader($container);
     $loader->loadFromFile(dirname(__DIR__) . '/data/services.yml');
     $this->assertEquals('called', $container->get('foo'));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:10,代码来源:YamlLoaderTest.php


示例14: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $container->share('cck', function ($container) {
         return new CCKEngine($container->get('app'), $container->get('event.dispatcher'), $container);
     });
     \JForm::addFieldPath(__DIR__ . '/Fields');
     \JForm::addFormPath(__DIR__ . '/Resource/Form');
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:17,代码来源:CCKProvider.php


示例15: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function register(Container $container)
 {
     $container->set('App\\Debug\\TrackerDebugger', function () use($container) {
         return new TrackerDebugger($container);
     }, true, true);
     // Alias the object
     $container->alias('debugger', 'App\\Debug\\TrackerDebugger');
 }
开发者ID:dextercowley,项目名称:jissues,代码行数:18,代码来源:DebuggerProvider.php


示例16: testEventDispatcherServiceProviderCreatesDispatcherWithAlias

 /**
  * @testdox The EventDispatcherServiceProvider adds an EventDispatcher to a container with an alias
  */
 public function testEventDispatcherServiceProviderCreatesDispatcherWithAlias()
 {
     $container = new Container();
     $container->set('extension_factory', $this->getMockBuilder(ExtensionFactoryInterface::class)->getMock());
     $service = new EventDispatcherServiceProvider();
     $service->register($container, 'unit');
     $this->assertInstanceOf(DispatcherInterface::class, $container->get('unit'));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:11,代码来源:EventDispatcherServiceProviderTest.php


示例17: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $container->set('Joomla\\Database\\DatabaseDriver', function () {
         return (new DatabaseDriver())->create($this->test, 'mysqli');
     }, true, true);
     // Alias the database
     $container->alias('db', 'Joomla\\Database\\DatabaseDriver');
 }
开发者ID:ratto,项目名称:framework.joomla.org,代码行数:17,代码来源:DatabaseProvider.php


示例18: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $operators = array('copy', 'convert');
     foreach ($operators as $operator) {
         $class = '\\CodeGenerator\\FileOperator\\' . ucfirst($operator) . 'Operator';
         $container->alias('operator.' . $operator, $class)->buildSharedObject($class);
     }
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:17,代码来源:ServiceProvider.php


示例19: testGetNewInstance

 /**
  * @testdox getNewInstance() will always return a new instance, even if the resource was set to be shared
  */
 public function testGetNewInstance()
 {
     $container = new Container();
     $container->share('foo', function () {
         return new \stdClass();
     });
     $this->assertNotSame($container->getNewInstance('foo'), $container->getNewInstance('foo'));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:11,代码来源:ContainerAccessTest.php


示例20: testExtensionFactoryServiceProviderCreatesExtensionFactoryWithAlias

 /**
  * @testdox The ExtensionFactoryServiceProvider adds an ExtensionFactory to a container with an alias
  */
 public function testExtensionFactoryServiceProviderCreatesExtensionFactoryWithAlias()
 {
     $container = new Container();
     $container->set('ConfigDirectory', __DIR__);
     $service = new ExtensionFactoryServiceProvider();
     $service->register($container, 'unit');
     $this->assertInstanceOf(ExtensionFactoryInterface::class, $container->get('unit'));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:11,代码来源:ExtensionFactoryServiceProviderTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Registry\Registry类代码示例发布时间:2022-05-23
下一篇:
PHP Model\MessageCatalogue类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap