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