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


PHP Container::bound方法代码示例

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


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

示例1: boot

 public function boot()
 {
     parent::boot();
     if (!$this->container->bound(JobSchedulerInterface::class)) {
         throw new CoreException('This module requires the Jobs component to be loaded. ' . 'Please make sure that `JobsServiceProvider` ' . 'is in your application\'s `config/app.php` file.');
     }
 }
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:7,代码来源:JobsModule.php

示例2: getConverterFor

 /**
  * Get the appropriate converter name for the given value.
  * TODO: Clean this up. A lot.
  *
  * @param mixed $value
  * @param bool $debug
  * @return string
  */
 public function getConverterFor($value, bool $debug = false)
 {
     $type = $this->getType($value);
     $config = app('Illuminate\\Contracts\\Config\\Repository');
     $defaults = collect($this->converterManager->getDefaultConverters())->merge($this->application['config']->get('laravel-xml.converters.defaults'))->filter(function ($item) {
         $item = is_array($item) ? $item['value'] : $item;
         return class_exists($item) or $this->container->bound($item);
     });
     $custom = collect($this->application['config']->get('laravel-xml.converters.custom'))->filter(function ($item) {
         $item = is_array($item) ? $item['value'] : $item;
         return class_exists($item) or $this->container->bound($item);
     });
     //        if ($debug) dd($custom);
     // Step one: Try to find the CLASS or TYPE in $custom
     $class = $custom->get(is_object($value) ? get_class($value) : str_plural($type), function () use($custom, $defaults, $value, $type) {
         // Step two: try to find the TYPE in $custom
         return $custom->get(str_plural($type), function () use($defaults, $value, $type) {
             // Step three: Try to find the CLASS or TYPE in $defaults
             return $defaults->get(is_object($value) ? get_class($value) : str_plural($type), function () use($defaults, $value, $type) {
                 // Step four: Try to find the TYPE in $defaults
                 return $defaults->get(str_plural($type), function () {
                     // If nothing works, throw an error.
                     throw new NoConverterFoundException("Could not find an appropriate converter.");
                 });
             });
         });
     });
     return is_array($class) ? isset($class['value']) ? $class['value'] : '' : $class;
 }
开发者ID:fetchleo,项目名称:laravel-xml,代码行数:37,代码来源:Xml.php

示例3: boot

 /**
  * Boot the module.
  *
  * @throws CoreException
  */
 public function boot()
 {
     parent::boot();
     if (!$this->container->bound(ApplicationManifestInterface::class)) {
         throw new CoreException('An instance of ApplicationManifest must be bound to in the ' . 'container in order to provide application reflection data.');
     }
 }
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:12,代码来源:ApplicationModule.php

示例4: setupContainer

 /**
  * Setup the IoC container instance.
  *
  * @param  \Illuminate\Contracts\Container\Container  $container
  * @return void
  */
 protected function setupContainer(Container $container)
 {
     $this->container = $container;
     if (!$this->container->bound('config')) {
         $this->container->instance('config', new Fluent());
     }
 }
开发者ID:Vinelab,项目名称:neoeloquent-support,代码行数:13,代码来源:CapsuleManagerTrait.php

示例5: has

 /**
  * {@inheritdoc}
  */
 public function has($id)
 {
     if ($this->hasIsCached($id)) {
         return $this->hasFromCache($id);
     }
     $has = $this->container->bound($id) || $this->isInstantiable($id);
     $this->cacheHas($id, $has);
     return $has;
 }
开发者ID:bweston92,项目名称:monii-container-interop-laravel,代码行数:12,代码来源:LaravelContainer.php

示例6: handleException

 /**
  * Handle the given exception.
  *
  * (Copy from Illuminate\Routing\Pipeline by Taylor Otwell)
  *
  * @param $passable
  * @param  Exception $e
  * @return mixed
  * @throws Exception
  */
 protected function handleException($passable, Exception $e)
 {
     if (!$this->container->bound(ExceptionHandler::class) || !$passable instanceof Request) {
         throw $e;
     }
     $handler = $this->container->make(ExceptionHandler::class);
     $handler->report($e);
     return $handler->render($passable, $e);
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:19,代码来源:Debugbar.php

示例7: addConnection

 /**
  * @param $connection
  */
 public function addConnection($connection)
 {
     if (!$this->container->bound($this->getConnectionBindingName($connection))) {
         $this->container->singleton($this->getConnectionBindingName($connection), function () use($connection) {
             return $this->getManager($connection)->getConnection();
         });
         $this->connections[$connection] = $connection;
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:12,代码来源:IlluminateRegistry.php

示例8: boot

 /**
  * Boot the module.
  *
  * @throws CoreException
  */
 public function boot()
 {
     parent::boot();
     if (!$this->container->bound(StructuredStatusInterface::class)) {
         throw new CoreException('This module requires the Structured service to be loaded. ' . 'Please make sure that `StructuredMigrationsServiceProvider` ' . 'is in your application\'s `config/app.php` file.');
     }
     if (!$this->container->bound(Batch::class)) {
         throw new CoreException('While the Structured service is loaded, there isn\'t a ' . 'Batch defined at the moment. Please define a Batch class ' . 'for your application and bind it using a service provider.');
     }
 }
开发者ID:sellerlabs,项目名称:illuminated,代码行数:15,代码来源:StructuredModule.php

示例9: setMailerDependencies

 /**
  * Set a few dependencies on the mailer instance.
  *
  * @return void
  */
 protected function setMailerDependencies()
 {
     $this->mailer->setContainer($this->app);
     if ($this->app->bound('Psr\\Log\\LoggerInterface')) {
         $this->mailer->setLogger($this->app->make('Psr\\Log\\LoggerInterface'));
     }
     if ($this->app->bound('queue')) {
         $this->mailer->setQueue($this->app['queue.connection']);
     }
 }
开发者ID:rustyrobotmedia,项目名称:mail,代码行数:15,代码来源:Mail.php

示例10: validate

 /**
  * Validate the request using the checkable class.
  *
  * @throws FailedCheckException
  */
 public function validate()
 {
     if ($this->container->bound('illuminated.skipCheckableRequest')) {
         return;
     }
     $check = $this->getCheckable();
     $result = $check->check($this->assemble($this->request));
     if ($result->failed()) {
         $this->handleFailure($check, $result);
     }
 }
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:16,代码来源:CheckableRequest.php

示例11: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve($name)
 {
     $value = $this->registrations[$name];
     if (is_string($value)) {
         // Check for `class@method` format.
         if (strpos($value, '@') >= 1) {
             $segments = explode('@', $value, 2);
             if ($this->container->bound($segments[0])) {
                 return [$this->container->make($segments[0]), $segments[1]];
             }
         }
         if ($this->container->bound($name)) {
             return $this->container->make($name);
         }
     }
     return parent::resolve($name);
 }
开发者ID:kalfheim,项目名称:sanitizer,代码行数:20,代码来源:LaravelRegistrar.php

示例12: getDefaultPayload

 /**
  * Get the default paylaod for the session.
  *
  * @param  string  $data
  * @return array
  */
 protected function getDefaultPayload($data)
 {
     $payload = ['payload' => base64_encode($data), 'last_activity' => time()];
     if ($this->container && $this->container->bound(Guard::class)) {
         $payload['user_id'] = $this->container->make(Guard::class)->id();
     }
     if ($this->container && $this->container->bound('request')) {
         $payload['ip_address'] = $this->container->make('request')->ip();
     }
     return $payload;
 }
开发者ID:Ratsuky,项目名称:framework,代码行数:17,代码来源:DatabaseSessionHandler.php

示例13: createConnection

 /**
  * Create a new connection instance.
  *
  * @param  string   $driver
  * @param  \PDO|\Closure     $connection
  * @param  string   $database
  * @param  string   $prefix
  * @param  array    $config
  * @return \Illuminate\Database\Connection
  *
  * @throws \InvalidArgumentException
  */
 protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
 {
     if ($this->container->bound($key = "db.connection.{$driver}")) {
         return $this->container->make($key, [$connection, $database, $prefix, $config]);
     }
     switch ($driver) {
         case 'mysql':
             return new MySqlConnection($connection, $database, $prefix, $config);
         case 'pgsql':
             return new PostgresConnection($connection, $database, $prefix, $config);
         case 'sqlite':
             return new SQLiteConnection($connection, $database, $prefix, $config);
         case 'sqlsrv':
             return new SqlServerConnection($connection, $database, $prefix, $config);
     }
     throw new InvalidArgumentException("Unsupported driver [{$driver}]");
 }
开发者ID:delatbabel,项目名称:framework,代码行数:29,代码来源:ConnectionFactory.php

示例14: getTranslator

 /**
  * Get a translator instance.
  *
  * @param  \Illuminate\Contracts\Container\Container $container
  * @return \Symfony\Component\Translation\TranslatorInterface
  */
 protected function getTranslator(Container $container = null)
 {
     if ($container && $container->bound('translator')) {
         return $container['translator'];
     }
     return new Translator();
 }
开发者ID:hazzardweb,项目名称:validation,代码行数:13,代码来源:Validator.php

示例15: runCommandInForeground

 /**
  * Run the command in the foreground.
  *
  * @param  \Illuminate\Contracts\Container\Container  $container
  * @return void
  */
 protected function runCommandInForeground(Container $container)
 {
     (new Process(trim($this->buildCommand(), '& '), base_path(), null, null, null))->run();
     if ($this->afterCallback) {
         $container->call($this->afterCallback);
     }
     if ($this->emailAddresses && $container->bound('Illuminate\\Contracts\\Mail\\Mailer')) {
         $this->emailOutput($container->make('Illuminate\\Contracts\\Mail\\Mailer'));
     }
 }
开发者ID:mmf,项目名称:framework,代码行数:16,代码来源:Event.php


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