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


PHP Container::bindIf方法代码示例

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


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

示例1: setupContainer

 /**
  * Bind required instances for the service provider.
  */
 protected function setupContainer()
 {
     $this->container->bindIf('files', function () {
         return new Filesystem();
     }, true);
     $this->container->bindIf('events', function () {
         return new Dispatcher();
     }, true);
     $this->container->bindIf('config', function () {
         return ['view.paths' => (array) $this->viewPaths, 'view.compiled' => $this->cachePath];
     }, true);
 }
开发者ID:ngangchill,项目名称:blade,代码行数:15,代码来源:Blade.php

示例2: bindCoreClasses

 /**
  * Bind core classes to the Container
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     $app->bindIf('events', function ($app) {
         return new Dispatcher($app);
     }, true);
     $app->bindIf('router', function ($app) {
         return new Router($app['events'], $app);
     }, true);
     $app->bind('url', function ($app) {
         return new UrlGenerator($app['router']->getRoutes(), $app['request']);
     });
     return $app;
 }
开发者ID:dvlpp,项目名称:warkham,代码行数:20,代码来源:WarkhamServiceProvider.php

示例3: bindCoreClasses

 /**
  * Bind the core classes to the Container
  *
  * @param  Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     // Cancel if in the scope of a Laravel application
     if ($app->bound('events')) {
         return $app;
     }
     // Core classes
     //////////////////////////////////////////////////////////////////
     $app->bindIf('files', 'Illuminate\\Filesystem\\Filesystem');
     $app->bindIf('url', 'Illuminate\\Routing\\UrlGenerator');
     // Session and request
     //////////////////////////////////////////////////////////////////
     $app->bindIf('session.manager', function ($app) {
         return new SessionManager($app);
     });
     $app->bindIf('session', function ($app) {
         return $app['session.manager']->driver('array');
     }, true);
     $app->bindIf('request', function ($app) {
         $request = Request::createFromGlobals();
         if (method_exists($request, 'setSessionStore')) {
             $request->setSessionStore($app['session']);
         } else {
             $request->setSession($app['session']);
         }
         return $request;
     }, true);
     // Config
     //////////////////////////////////////////////////////////////////
     $app->bindIf('path.config', function ($app) {
         dd(__DIR__ . '/../config/');
         return __DIR__ . '/../config/';
     }, true);
     $app->bindIf('config', function ($app) {
         $config = new Repository();
         $this->loadConfigurationFiles($app, $config);
         return $config;
     }, true);
     // Localization
     //////////////////////////////////////////////////////////////////
     $app->bindIf('translation.loader', function ($app) {
         return new FileLoader($app['files'], 'src/config');
     });
     $app->bindIf('translator', function ($app) {
         $loader = new FileLoader($app['files'], 'lang');
         return new Translator($loader, 'fr');
     });
     return $app;
 }
开发者ID:laralite,项目名称:form,代码行数:56,代码来源:FormServiceProvider.php

示例4: ensureIlluminateBase

 /**
  * Ensure the base event and file bindings are present. Required for binding anything else.
  *
  * @param  Container  $app
  * @return void
  */
 public function ensureIlluminateBase(Container $app = null)
 {
     if (!$app->bound('events')) {
         $app->singleton('events', $this->illuminateClasses['events']);
         $app['events']->fire('booting');
     }
     if (!$app->bound('files')) {
         $app->bindIf('files', $this->illuminateClasses['files']);
     }
 }
开发者ID:caffeinated,项目名称:beverage,代码行数:16,代码来源:BindIlluminate.php

示例5: bindCoreClasses

 /**
  * Bind the core classes
  *
  * @param  Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     if ($app->bound('events')) {
         return $app;
     }
     $app->bindIf('request', function ($app) {
         return Request::createFromGlobals();
     });
     $app->bindIf('url', function ($app) {
         $routes = new RouteCollection();
         return new UrlGenerator($routes, $app['request']);
     });
     $app->bindIf('html', function ($app) {
         return new HtmlBuilder($app['url']);
     });
     $app->bindIf('path.public', function () {
         return realpath(__DIR__ . '/../../');
     });
     return $app;
 }
开发者ID:anahkiasen,项目名称:acetone,代码行数:27,代码来源:AcetoneServiceProvider.php

示例6: bindIf

 /**
  * Register a binding if it hasn't already been registered.
  *
  * @param  string $abstract
  * @param  \Closure|string|null $concrete
  * @param  bool $shared
  * @return void
  */
 public function bindIf($abstract, $concrete = null, $shared = false)
 {
     if (!$this->parentContainer->bound($abstract) && !$this->bound($abstract)) {
         parent::bindIf($abstract, $concrete, $shared);
     }
 }
开发者ID:e1stuff,项目名称:layered-laravel-container,代码行数:14,代码来源:LayeredContainer.php

示例7: bindCoreClasses

 /**
  * Bind the core classes
  *
  * @param  Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     $app->bindIf('files', 'Illuminate\\Filesystem\\Filesystem');
     $app->bindIf('request', function () {
         return Request::createFromGlobals();
     }, true);
     $app->bindIf('config', function ($app) {
         $fileloader = new FileLoader($app['files'], __DIR__ . '/../config');
         return new Repository($fileloader, 'config');
     }, true);
     $app->bindIf('remote', function ($app) {
         return new RemoteManager($app);
     }, true);
     $app->bindIf('events', function ($app) {
         return new Dispatcher($app);
     }, true);
     $app->bindIf('log', function () {
         return new Writer(new Logger('rocketeer'));
     }, true);
     // Register factory and custom configurations
     $app = $this->registerConfig($app);
     return $app;
 }
开发者ID:denji,项目名称:rocketeer,代码行数:30,代码来源:RocketeerServiceProvider.php

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

示例9: bindClasses

 /**
  * Bind Illuminage's classes
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindClasses(Container $app)
 {
     // Register config file
     $app['config']->package('anahkiasen/illuminage', __DIR__ . '/../config');
     $app->bindIf('illuminage', function ($app) {
         return new Illuminage($app);
     });
     $app->bindIf('imagine', function ($app) {
         $engine = $app['illuminage']->getOption('image_engine');
         $imagine = "\\Imagine\\{$engine}\\Imagine";
         return new $imagine();
     });
     $app->bindIf('illuminage.processor', function ($app) {
         return new ImageProcessor($app['imagine']);
     });
     $app->bindIf('illuminage.cache', function ($app) {
         return new Cache($app['illuminage']);
     });
     // Set cache folder if non existing
     $cache = $app['illuminage']->getPublicFolder() . '/' . $app['config']->get('illuminage::cache_folder');
     if (!file_exists($cache)) {
         $app['config']->set('illuminage::cache_folder', 'public/');
     }
     return $app;
 }
开发者ID:anahkiasen,项目名称:illuminage,代码行数:32,代码来源:IlluminageServiceProvider.php

示例10: bindCoreClasses

 /**
  * Bind the core classes
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindCoreClasses(Container $app)
 {
     $app->bindIf('files', 'Illuminate\\Filesystem\\Filesystem');
     $app->bindIf('config', function ($app) {
         $fileloader = new FileLoader($app['files'], __DIR__ . '/../config');
         return new Repository($fileloader, 'config');
     }, true);
     // Register factory and custom configurations
     $app = $this->registerConfig($app);
     return $app;
 }
开发者ID:summer11123,项目名称:trucker,代码行数:18,代码来源:TruckerServiceProvider.php


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