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


PHP Container::alias方法代码示例

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


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

示例1: registerCache

 protected function registerCache()
 {
     $this->app->singleton('cache', function ($app) {
         return new \Illuminate\Cache\CacheManager($app);
     });
     $this->app->singleton('cache.store', function ($app) {
         return $app['cache']->driver();
     });
     $this->app->alias('cache', \Illuminate\Contracts\Cache\Factory::class);
 }
开发者ID:ytake,项目名称:laravel-aspect,代码行数:10,代码来源:AspectTestCase.php

示例2: singleton

 /**
  * Add a singleton definition to the container.
  * Not sure if generally required, but this call quietly wraps non-callable $concrete
  * implementations with an anonymous function. (i.e.: Simplifies illuminate/container call.)
  *
  * @param  string|array $abstract
  * @param  mixed        $concrete
  *
  * @return void
  */
 public function singleton($abstract, $concrete = NULL)
 {
     $alias = NULL;
     if (is_array($abstract)) {
         $alias = $abstract[0];
         $abstract = $abstract[1];
         # register the alias because the alias is provided
         static::$container->alias($abstract, $alias);
     }
     if (!is_callable($concrete)) {
         static::$container->singleton($abstract, function () use($concrete) {
             return $concrete;
         });
     }
     if (is_callable($concrete)) {
         static::$container->singleton($abstract, $concrete);
     }
 }
开发者ID:anctemarry27,项目名称:cogs,代码行数:28,代码来源:Forge.php

示例3: bindForm

 /**
  * Bind Form classes to the container
  *
  * @param  Container $app
  *
  * @return Container
  */
 public function bindForm(Container $app)
 {
     // Add config namespace
     $configPath = __DIR__ . '/../config/form.php';
     $this->mergeConfigFrom($configPath, 'form');
     $this->publishes([$configPath => $app['path.config'] . '/form.php']);
     $framework = $app['config']->get('form.framework');
     $app->bind('form.framework', function ($app) {
         return $app['form']->getFrameworkInstance($app['config']->get('form.framework'));
     });
     $app->singleton('form.populator', function ($app) {
         return new Populator();
     });
     $app->singleton('form.dispatcher', function ($app) {
         return new MethodDispatcher($app, Form::FIELDSPACE);
     });
     $app->singleton('form', function ($app) {
         return new Form($app, $app->make('form.dispatcher'));
     });
     $app->alias('form', 'Form\\Form');
     Helpers::setApp($app);
     return $app;
 }
开发者ID:laralite,项目名称:form,代码行数:30,代码来源:FormServiceProvider.php

示例4: getContainer

 /**
  * Get the current dependencies
  *
  * @param string $dependency A dependency to make on the fly
  *
  * @return Container
  */
 public static function getContainer($dependency = null)
 {
     if (!static::$container) {
         $container = new Container();
         // Create HTML
         $container->bindIf('html', 'LaravelBook\\Laravel4Powerpack\\HTML');
         // Create basic Request instance to use
         $container->alias('Symfony\\Component\\HttpFoundation\\Request', 'request');
         $container->bindIf('Symfony\\Component\\HttpFoundation\\Request', function () {
             return Request::createFromGlobals();
         });
         static::setContainer($container);
     }
     // Shortcut for getting a dependency
     if ($dependency) {
         return static::$container->make($dependency);
     }
     return static::$container;
 }
开发者ID:memeq1,项目名称:menu,代码行数:26,代码来源:Menu.php

示例5: alias

 /**
  * @param string       $abstract
  * @param array|string $alias
  */
 public function alias($abstract, $alias)
 {
     foreach ((array) $alias as $item) {
         $this->container->alias($abstract, $item);
     }
 }
开发者ID:notadd,项目名称:framework,代码行数:10,代码来源:ExtensionRegistrar.php

示例6: alias

 /**
  * Alias a type to a different name.
  *
  * @param string $abstract
  * @param string $alias
  */
 public function alias($abstract, $alias)
 {
     $this->delegate->alias($abstract, $alias);
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:10,代码来源:Container.php

示例7: bindFormer

 /**
  * Bind Former classes to the container.
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindFormer(Container $app)
 {
     $framework = $app['config']->get('former.framework');
     $app->bind('former.framework', function ($app) {
         return $app['former']->getFrameworkInstance($app['config']->get('former.framework'));
     });
     $app->singleton('former.populator', function ($app) {
         return new \Former\Populator();
     });
     $app->singleton('former.dispatcher', function ($app) {
         return new \Former\MethodDispatcher($app, \Former\Former::FIELDSPACE);
     });
     $app->singleton('former', function ($app) {
         return new \Former\Former($app, $app->make('former.dispatcher'));
     });
     $app->alias('former', 'Former\\Former');
     \Former\Helpers::setApp($app);
     return $app;
 }
开发者ID:LavaLite,项目名称:framework,代码行数:26,代码来源:FormServiceProvider.php


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