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


PHP Container::bind方法代码示例

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


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

示例1: add

 /**
  * @param string $class
  * @param int $priority
  * @return Storage
  */
 public function add($class, $priority = self::PRIORITY_DEFAULT) : Storage
 {
     $this->container->bind($class, $class);
     $instance = $this->container->make($class);
     $this->storage->insert($instance, $priority);
     return $this;
 }
开发者ID:Dualse,项目名称:GitterBot,代码行数:12,代码来源:Storage.php

示例2: registerContainerBindings

 /**
  * @param Container $container
  */
 protected function registerContainerBindings(Container $container)
 {
     $entityManager = $container->make('Doctrine\\ORM\\EntityManagerInterface');
     $container->bind('Crisu83\\Overseer\\Storage\\RoleStorage', function () use($entityManager) {
         return new RoleStorage($entityManager);
     });
     $container->bind('Crisu83\\Overseer\\Storage\\PermissionStorage', function () use($entityManager) {
         return new PermissionStorage($entityManager);
     });
     $container->bind('Crisu83\\Overseer\\Storage\\AssignmentStorage', function () use($entityManager) {
         return new AssignmentStorage($entityManager);
     });
 }
开发者ID:nordsoftware,项目名称:lumen-rbac,代码行数:16,代码来源:DoctrineStorageServiceProvider.php

示例3: registerBindings

 /**
  * Registers container bindings.
  *
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerBindings(Container $container, ConfigRepository $config)
 {
     $container->bind(OAuth2Service::class, function ($container) use($config) {
         return $this->createService($container, $config[self::CONFIG_KEY]);
     });
     $container->alias(OAuth2Service::class, OAuth2ServiceContract::class);
 }
开发者ID:nordsoftware,项目名称:lumen-oauth2,代码行数:13,代码来源:OAuth2ServiceProvider.php

示例4: registerBindings

 /**
  * Register the bindings.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  *
  * @return void
  */
 protected function registerBindings(Application $app)
 {
     $app->bind('telegram.bot', function ($app) {
         $manager = $app['telegram'];
         return $manager->bot();
     });
     $app->alias('telegram.bot', Api::class);
 }
开发者ID:irazasyed,项目名称:telegram-bot-sdk,代码行数:15,代码来源:TelegramServiceProvider.php

示例5: bindContext

 /**
  * Bind the given security context to the Request and Container.
  *
  * @param string  $context
  * @param Request $request
  */
 public function bindContext($context, Request $request)
 {
     $security = $this->getSecurity($context);
     $this->container->instance(SecurityApi::class, $security);
     $this->container->bind(UrlGeneratorContract::class, function () use($security) {
         return $security->url();
     });
     $this->container->bind([UrlGenerator::class => 'url'], function (Container $container) use($security) {
         /** @var PermissionAwareUrlGeneratorExtension $url */
         $url = $container->make(PermissionAwareUrlGeneratorExtension::class);
         $url->setUrlGenerator($security->url());
         return $url;
     });
     $request->setUserResolver(function () use($security) {
         return $security->getUser();
     });
 }
开发者ID:digbang,项目名称:security,代码行数:23,代码来源:SecurityContext.php

示例6: register

 public function register(Container $container)
 {
     $container->bind(Relay::class, function (Container $container) {
         /** @var RelayBuilder $relayBuilder */
         $relayBuilder = $container->make(RelayBuilder::class);
         $queue = array_merge([$container->make(ResponseSender::class), $container->make(NikicFastRoute::class, ['actionAttributeName' => App::DEFAULT_ACTION_ATTRIBUTE_NAME, 'parametersAttributeName' => App::DEFAULT_PARAMETERS_ATTRIBUTE_NAME])], $container->tagged('middleware.error_handler'), $container->tagged('middleware.early'), $container->tagged('middleware'), $container->tagged('middleware.late'), [$container->make(ActionHandler::class, ['actionAttributeName' => App::DEFAULT_ACTION_ATTRIBUTE_NAME])]);
         return $relayBuilder->newInstance($queue);
     });
 }
开发者ID:simensen,项目名称:monii-nimble-framework,代码行数:9,代码来源:RelayServiceProvider.php

示例7: register

 public function register(Container $container)
 {
     $container->bind(FastRoute\Dispatcher::class, function (Container $container) {
         $routeCollector = $container->make(FastRoute\RouteCollector::class);
         return new FastRoute\Dispatcher\GroupCountBased($routeCollector->getData());
     });
     $container->bind(FastRoute\RouteParser::class, FastRoute\RouteParser\Std::class);
     $container->bind(FastRoute\DataGenerator::class, FastRoute\DataGenerator\GroupCountBased::class);
     $container->afterResolving(FastRoute\RouteCollector::class, function (FastRoute\RouteCollector $routeCollector, Container $container) {
         /** @var RouteProvider $routeProvider */
         foreach ($container->tagged('route_provider') as $routeProvider) {
             $routeProvider->addRoutes($routeCollector);
         }
     });
     $container->bind(ParametersReader::class, function () {
         return new ParametersReader(App::DEFAULT_PARAMETERS_ATTRIBUTE_NAME);
     });
 }
开发者ID:simensen,项目名称:monii-nimble-framework,代码行数:18,代码来源:NikicFastRouteServiceProvider.php

示例8: solidify

 /**
  * Binds the previous virtual binding into the Laravel service container.
  * This will map the interface to the concrete class, then create an alias
  * for the interface so it can later be referenced by its short name.
  */
 public function solidify()
 {
     if (count($this->lastBinding) < 2) {
         throw new BindingException("Container injection can't be completed as a previous " . "binding operation hasn't yet to occur.");
     }
     $alias = $this->lastBinding['alias'];
     $concrete = $this->lastBinding['concrete'];
     $this->container->bind($alias, function ($app) use($concrete) {
         return $app->make($concrete);
     });
 }
开发者ID:enzyme,项目名称:laravel-binder,代码行数:16,代码来源:Binder.php

示例9: upgrade

 protected function upgrade()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Migrations\\Migrator');
     $migrator->run(base_path('core/migrations'));
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
     $extensions = $this->container->make('Flarum\\Support\\ExtensionManager');
     $migrator = $extensions->getMigrator();
     foreach ($extensions->getInfo() as $extension) {
         $this->info('Upgrading extension: ' . $extension->name);
         $extensions->enable($extension->name);
         foreach ($migrator->getNotes() as $note) {
             $this->info($note);
         }
     }
 }
开发者ID:huytd,项目名称:core,代码行数:20,代码来源:UpgradeCommand.php

示例10: runMigrations

 protected function runMigrations()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Migrations\\Migrator');
     $migrator->getRepository()->createRepository();
     $migrator->run(__DIR__ . '/../../../migrations');
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
 }
开发者ID:huytd,项目名称:core,代码行数:12,代码来源:InstallCommand.php

示例11: registerContainerBindings

 /**
  * @param Container $container
  */
 protected function registerContainerBindings(Container $container)
 {
     $container->bind(AccessTokenStorage::class, function () {
         return new AccessTokenStorage();
     });
     $container->bind(ClientStorage::class, function () {
         return new ClientStorage();
     });
     $container->bind(RefreshTokenStorage::class, function () {
         return new RefreshTokenStorage();
     });
     $container->bind(ScopeStorage::class, function () {
         return new ScopeStorage();
     });
     $container->bind(SessionStorage::class, function () {
         return new SessionStorage();
     });
     $container->bind(AccessTokenInterface::class, AccessTokenStorage::class);
     $container->bind(ClientInterface::class, ClientStorage::class);
     $container->bind(RefreshTokenInterface::class, RefreshTokenStorage::class);
     $container->bind(ScopeInterface::class, ScopeStorage::class);
     $container->bind(SessionInterface::class, SessionStorage::class);
 }
开发者ID:nordsoftware,项目名称:lumen-oauth2-dynamodb,代码行数:26,代码来源:DynamoDBServiceProvider.php

示例12: upgrade

 public function upgrade()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Database\\Migrator');
     $migrator->run(base_path('core/migrations'));
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
     $extensions = $this->container->make('Flarum\\Extension\\ExtensionManager');
     $migrator = $extensions->getMigrator();
     foreach ($extensions->getInfo() as $name => $extension) {
         if (!$extensions->isEnabled($name)) {
             continue;
         }
         $this->info('Migrating extension: ' . $name);
         $extensions->migrate($name);
         foreach ($migrator->getNotes() as $note) {
             $this->info($note);
         }
     }
     $this->container->make('Flarum\\Settings\\SettingsRepositoryInterface')->set('version', $this->container->version());
 }
开发者ID:RudolfFussek,项目名称:core,代码行数:24,代码来源:MigrateCommand.php

示例13: getRequest

 /**
  * @param ReflectionParameter[] $arguments
  *
  * @return Request|null
  */
 public function getRequest(array $arguments)
 {
     foreach ($arguments as $argument) {
         if ($argument->getClass() === null) {
             continue;
         }
         $type = $argument->getClass()->getName();
         if ($type === ApiCheckableRequest::class || in_array(ApiCheckableRequest::class, class_parents($type))) {
             $this->app->bind('illuminated.skipCheckableRequest', true);
             $instance = $this->app->make($type);
             if ($instance instanceof ApiCheckableRequest) {
                 return $instance;
             }
         }
     }
     return null;
 }
开发者ID:MarkVaughn,项目名称:illuminated,代码行数:22,代码来源:ResourceReflector.php

示例14: weave

 /**
  * weaving
  */
 public function weave()
 {
     if (is_null($this->aspectResolver)) {
         return;
     }
     foreach ($this->aspectResolver->getResolver() as $class => $pointcuts) {
         $bind = (new AspectBind($this->filesystem, $this->configure['cache_dir'], $this->cacheable))->bind($class, $pointcuts);
         $compiledClass = $this->compiler->compile($class, $bind);
         if (isset($this->app->contextual[$class])) {
             $this->resolveContextualBindings($class, $compiledClass);
         }
         $this->app->bind($class, function (Container $app) use($bind, $compiledClass) {
             $instance = $app->make($compiledClass);
             $instance->bindings = $bind->getBindings();
             return $instance;
         });
     }
 }
开发者ID:ytake,项目名称:laravel-aspect,代码行数:21,代码来源:RayAspectKernel.php

示例15: registerInterfaceBindings

 /**
  * Bind the interfaces to their implementations.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 public function registerInterfaceBindings(Application $app)
 {
     $app->bind(ClientInterface::class, FluentClient::class);
     $app->bind(ScopeInterface::class, FluentScope::class);
     $app->bind(SessionInterface::class, FluentSession::class);
     $app->bind(AuthCodeInterface::class, FluentAuthCode::class);
     $app->bind(AccessTokenInterface::class, FluentAccessToken::class);
     $app->bind(RefreshTokenInterface::class, FluentRefreshToken::class);
 }
开发者ID:h4r5h4,项目名称:oauth2-server-laravel,代码行数:16,代码来源:FluentStorageServiceProvider.php


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