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


PHP DI\Container类代码示例

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


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


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