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


PHP Container::alias方法代码示例

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


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

示例1: 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)
 {
     // Application
     $container->alias('app', 'JApplicationCms')->share('JApplicationCms', array('JFactory', 'getApplication'));
     // Document
     $container->alias('document', 'JDocumentHtml')->share('JDocumentHtml', array('JFactory', 'getDocument'));
     // User
     $container->alias('user', 'JUser')->share('JUser', \JFactory::getUser());
     // Input
     $container->alias('input', 'JInput')->share('JInput', \JFactory::getApplication()->input);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:18,代码来源:WebProvider.php

示例2: 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('Stats\\Application', 'Joomla\\Application\\AbstractApplication')->alias('Joomla\\Application\\AbstractWebApplication', 'Joomla\\Application\\AbstractApplication')->share('Joomla\\Application\\AbstractApplication', function (Container $container) {
         $application = new Application($container->get('Joomla\\Input\\Input'), $container->get('config'));
         // Inject extra services
         $application->setRouter($container->get('Stats\\Router'));
         return $application;
     }, true);
     $container->share('Joomla\\Input\\Input', function () {
         return new Input($_REQUEST);
     }, true);
     $container->share('Stats\\Router', function (Container $container) {
         $router = (new Router($container->get('Joomla\\Input\\Input')))->setContainer($container)->setControllerPrefix('Stats\\Controllers\\')->setDefaultController('DisplayController')->addMap('/submit', 'SubmitController')->addMap('/:source', 'DisplayController');
         return $router;
     }, true);
     $container->share('Stats\\Controllers\\DisplayControllerGet', function (Container $container) {
         $controller = new DisplayControllerGet($container->get('Stats\\Views\\Stats\\StatsJsonView'));
         $controller->setApplication($container->get('Joomla\\Application\\AbstractApplication'));
         $controller->setInput($container->get('Joomla\\Input\\Input'));
         return $controller;
     }, true);
     $container->share('Stats\\Controllers\\SubmitControllerCreate', function (Container $container) {
         $controller = new SubmitControllerCreate($container->get('Stats\\Models\\StatsModel'));
         $controller->setApplication($container->get('Joomla\\Application\\AbstractApplication'));
         $controller->setInput($container->get('Joomla\\Input\\Input'));
         return $controller;
     }, true);
     $container->share('Stats\\Models\\StatsModel', function (Container $container) {
         return new StatsModel($container->get('Joomla\\Database\\DatabaseDriver'));
     }, true);
     $container->share('Stats\\Views\\Stats\\StatsJsonView', function (Container $container) {
         return new StatsJsonView($container->get('Stats\\Models\\StatsModel'));
     }, true);
 }
开发者ID:alikon,项目名称:jstats-server,代码行数:43,代码来源:ApplicationServiceProvider.php

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

示例4: register

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

示例5: 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)
 {
     // Register the web processor
     $container->share('monolog.processor.web', function () {
         return new WebProcessor();
     });
     // Register the main application handler
     $container->share('monolog.handler.application', function (Container $container) {
         /** @var \Joomla\Registry\Registry $config */
         $config = $container->get('config');
         $level = strtoupper($config->get('log.application', $config->get('log.level', 'error')));
         return new StreamHandler(APPROOT . '/logs/app.log', constant('\\Monolog\\Logger::' . $level));
     });
     // Register the database handler
     $container->share('monolog.handler.database', function (Container $container) {
         /** @var \Joomla\Registry\Registry $config */
         $config = $container->get('config');
         // If database debugging is enabled then force the logger's error level to DEBUG, otherwise use the level defined in the app config
         $level = $config->get('database.debug', false) ? 'DEBUG' : strtoupper($config->get('log.database', $config->get('log.level', 'error')));
         return new StreamHandler(APPROOT . '/logs/database.log', constant('\\Monolog\\Logger::' . $level));
     });
     // Register the main Logger
     $container->alias('monolog', 'Monolog\\Logger')->alias('monolog.logger.application', 'Monolog\\Logger')->alias('Psr\\Log\\LoggerInterface', 'Monolog\\Logger')->share('Monolog\\Logger', function (Container $container) {
         return new Logger('MauticDashboard', [$container->get('monolog.handler.application')], [$container->get('monolog.processor.web')]);
     });
     // Register the database Logger
     $container->share('monolog.logger.database', function (Container $container) {
         return new Logger('MauticDashboard', [$container->get('monolog.handler.database')], [$container->get('monolog.processor.web')]);
     });
 }
开发者ID:phproberto,项目名称:jstats-server,代码行数:39,代码来源:MonologServiceProvider.php

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

示例7: register

 /**
  * Add the plugin factory to a container
  *
  * @param   Container $container The container
  * @param   string    $alias     An optional alias
  *
  * @return  void
  */
 public function register(Container $container, $alias = null)
 {
     $container->set($this->key, [$this, 'createExtensionFactory'], true, true);
     if (!empty($alias)) {
         $container->alias($alias, $this->key);
     }
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:15,代码来源:ExtensionFactoryServiceProvider.php

示例8: register

 /**
  * Registers a RepositoryFactory with the container
  *
  * @param   Container $container The DI container
  * @param   string    $alias     An optional alias
  *
  * @return  void
  */
 public function register(Container $container, $alias = null)
 {
     $container->set('Repository', [$this, 'createRepositoryFactory'], true, true);
     if (!empty($alias)) {
         $container->alias($alias, 'Repository');
     }
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:15,代码来源:StorageServiceProvider.php

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

示例10: register

 /**
  * Add the dispatcher to a container
  *
  * @param   Container $container The container
  * @param   string    $alias     An optional alias
  *
  * @return  void
  */
 public function register(Container $container, $alias = null)
 {
     $container->set($this->key, [$this, 'createDispatcher'], true, true);
     if (!empty($alias)) {
         $container->alias($alias, $this->key);
     }
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:15,代码来源:EventDispatcherServiceProvider.php

示例11: 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)
 {
     $name = $this->name;
     // Component
     $container->alias('component', ucfirst($name) . 'Component')->share(ucfirst($name) . 'Component', $this->component);
     // ControllerResolver
     $resolverClass = '\\Windwalker\\Controller\\Resolver\\ControllerResolver';
     $container->alias('controller.resolver', $resolverClass)->share($resolverClass, function ($container) use($resolverClass) {
         return new $resolverClass($container->get('app'), $container);
     });
     // Asset Helper
     $container->extend('helper.asset', function ($asset, $container) use($name) {
         $asset->resetPaths();
         $asset = clone $asset;
         return $asset->setName('com_' . strtolower($name))->setContainer($container);
     });
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:24,代码来源:ComponentProvider.php

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

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

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

示例15: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  Container  Returns the container to support chaining.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function register(Container $container)
 {
     $container->share('JTracker\\Github\\Github', function () use($container) {
         // Call the Github factory's getInstance method and inject the application; it handles the rest of the configuration
         return GithubFactory::getInstance($container->get('app'));
     }, true);
     // Alias the object
     $container->alias('gitHub', 'JTracker\\Github\\Github');
 }
开发者ID:dextercowley,项目名称:jissues,代码行数:19,代码来源:GitHubProvider.php


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