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


PHP Container::alias方法代码示例

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


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

示例1: registerContainerBindings

 /**
  * @param Container        $container
  * @param ConfigRepository $config
  *
  * @throws Exception
  */
 protected function registerContainerBindings(Container $container, ConfigRepository $config)
 {
     if (!isset($config['rbac'])) {
         throw new Exception('RBAC configuration not registered.');
     }
     $rbacConfig = $config['rbac'];
     $container->alias('Nord\\Lumen\\Rbac\\RbacService', 'Nord\\Lumen\\Rbac\\Contracts\\RbacService');
     $container->alias($rbacConfig['subjectProvider'], 'Nord\\Lumen\\Rbac\\Contracts\\SubjectProvider');
     $container->singleton('Nord\\Lumen\\Rbac\\RbacService', function () use($container) {
         return $this->createService($container);
     });
 }
开发者ID:nordsoftware,项目名称:lumen-rbac,代码行数:18,代码来源:RbacServiceProvider.php

示例2: registerAuthorizer

 /**
  * Register the Authorization server with the IoC container.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  *
  * @return void
  */
 public function registerAuthorizer(Application $app)
 {
     $app->singleton('oauth2-server.authorizer', function ($app) {
         $config = $app['config']->get('oauth2');
         $issuer = $app->make(AuthorizationServer::class)->setClientStorage($app->make(ClientInterface::class))->setSessionStorage($app->make(SessionInterface::class))->setAuthCodeStorage($app->make(AuthCodeInterface::class))->setAccessTokenStorage($app->make(AccessTokenInterface::class))->setRefreshTokenStorage($app->make(RefreshTokenInterface::class))->setScopeStorage($app->make(ScopeInterface::class))->requireScopeParam($config['scope_param'])->setDefaultScope($config['default_scope'])->requireStateParam($config['state_param'])->setScopeDelimiter($config['scope_delimiter'])->setAccessTokenTTL($config['access_token_ttl']);
         // add the supported grant types to the authorization server
         foreach ($config['grant_types'] as $grantIdentifier => $grantParams) {
             $grant = $app->make($grantParams['class']);
             $grant->setAccessTokenTTL($grantParams['access_token_ttl']);
             if (array_key_exists('callback', $grantParams)) {
                 list($className, $method) = array_pad(explode('@', $grantParams['callback']), 2, 'verify');
                 $verifier = $app->make($className);
                 $grant->setVerifyCredentialsCallback([$verifier, $method]);
             }
             if (array_key_exists('auth_token_ttl', $grantParams)) {
                 $grant->setAuthTokenTTL($grantParams['auth_token_ttl']);
             }
             if (array_key_exists('refresh_token_ttl', $grantParams)) {
                 $grant->setRefreshTokenTTL($grantParams['refresh_token_ttl']);
             }
             if (array_key_exists('rotate_refresh_tokens', $grantParams)) {
                 $grant->setRefreshTokenRotation($grantParams['rotate_refresh_tokens']);
             }
             $issuer->addGrantType($grant, $grantIdentifier);
         }
         $checker = $app->make(ResourceServer::class);
         $authorizer = new Authorizer($issuer, $checker);
         $authorizer->setRequest($app['request']);
         $authorizer->setTokenType($app->make($config['token_type']));
         $app->refresh('request', $authorizer, 'setRequest');
         return $authorizer;
     });
     $app->alias('oauth2-server.authorizer', Authorizer::class);
 }
开发者ID:catlabinteractive,项目名称:laravel-charon,代码行数:41,代码来源:ServiceProvider.php

示例3: registerContainerBindings

 /**
  * Registers container bindings.
  *
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerContainerBindings(Container $container, ConfigRepository $config)
 {
     $container->singleton('Doctrine\\ORM\\EntityManager', function () use($config) {
         return $this->createEntityManager($config);
     });
     $container->alias('Doctrine\\ORM\\EntityManager', 'Doctrine\\ORM\\EntityManagerInterface');
 }
开发者ID:jaschweder,项目名称:lumen-doctrine,代码行数:13,代码来源:DoctrineServiceProvider.php

示例4: registerContainerBindings

 /**
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerContainerBindings(Container $container, ConfigRepository $config)
 {
     $container->alias(ImageManager::class, ImageManagerContract::class);
     $container->singleton(ImageManagerContract::class, function () use($container, $config) {
         return $this->createManager($container, $config);
     });
 }
开发者ID:nordsoftware,项目名称:lumen-image-manager,代码行数:11,代码来源:ImageManagerServiceProvider.php

示例5: registerBindings

 /**
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerBindings(Container $container, ConfigRepository $config)
 {
     $container->singleton(SparkPostService::class, function () use($config) {
         return new SparkPostService($config[self::CONFIG_KEY]);
     });
     $container->alias(SparkPostService::class, SparkPostServiceContract::class);
 }
开发者ID:nordsoftware,项目名称:lumen-sparkpost,代码行数:11,代码来源:SparkPostServiceProvider.php

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

示例7: registerBindings

 /**
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerBindings(Container $container, ConfigRepository $config)
 {
     $container->singleton(FractalService::class, function () use($config) {
         $fractal = new FractalService();
         $this->configureService($fractal, $config[self::CONFIG_KEY]);
         return $fractal;
     });
     $container->alias(FractalService::class, FractalServiceContract::class);
 }
开发者ID:nordsoftware,项目名称:lumen-fractal,代码行数:13,代码来源:FractalServiceProvider.php

示例8: registerAnalytics

 /**
  * Initialize Analytics Library with Default Config.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  */
 protected function registerAnalytics(Application $app)
 {
     $app->singleton('gamp', function ($app) {
         $config = $app['config'];
         $analytics = new Analytics($config->get('gamp.is_ssl', false));
         $analytics->setProtocolVersion($config->get('gamp.protocol_version', 1))->setTrackingId($config->get('gamp.tracking_id'));
         if ($config->get('gamp.anonymize_ip', false)) {
             $analytics->setAnonymizeIp('1');
         }
         if ($config->get('gamp.async_requests', false)) {
             $analytics->setAsyncRequest(true);
         }
         return $analytics;
     });
     $app->alias('gamp', Analytics::class);
 }
开发者ID:irazasyed,项目名称:laravel-gamp,代码行数:21,代码来源:LaravelGAMPServiceProvider.php

示例9: register

 /**
  * Register an addon.
  *
  * @param $path
  * @param $enabled
  * @param $installed
  */
 public function register($path, array $enabled, array $installed)
 {
     if (!is_dir($path)) {
         return;
     }
     $vendor = strtolower(basename(dirname($path)));
     $slug = strtolower(substr(basename($path), 0, strpos(basename($path), '-')));
     $type = strtolower(substr(basename($path), strpos(basename($path), '-') + 1));
     $class = studly_case($vendor) . '\\' . studly_case($slug) . studly_case($type) . '\\' . studly_case($slug) . studly_case($type);
     /* @var Addon|Module|Extension|Twig_ExtensionInterface $addon */
     $addon = app($class)->setPath($path)->setType($type)->setSlug($slug)->setVendor($vendor);
     // If the addon supports states - set the state now.
     if ($addon->getType() === 'module' || $addon->getType() === 'extension') {
         $addon->setInstalled(in_array($addon->getNamespace(), $installed));
         $addon->setEnabled(in_array($addon->getNamespace(), $enabled));
     }
     // Bind to the service container.
     $this->container->alias($addon->getNamespace(), $alias = get_class($addon));
     $this->container->instance($alias, $addon);
     // Load package configuration.
     $this->configurator->addNamespace($addon->getNamespace(), $addon->getPath('resources/config'));
     // Load system overrides.
     $this->configurator->addNamespaceOverrides($addon->getNamespace(), base_path('resources/addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType()));
     // Load application overrides.
     $this->configurator->addNamespaceOverrides($addon->getNamespace(), $this->application->getResourcesPath('addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType() . '/config'));
     // Continue loading things.
     $this->provider->register($addon);
     // Add the view / translation namespaces.
     $this->views->addNamespace($addon->getNamespace(), $addon->getPath('resources/views'));
     $this->translator->addNamespace($addon->getNamespace(), $addon->getPath('resources/lang'));
     /*
      * If the addon is a plugin then
      * load it into Twig when appropriate.
      */
     if ($addon->getType() === 'plugin') {
         $this->events->listen('Anomaly\\Streams\\Platform\\View\\Event\\RegisteringTwigPlugins', function (RegisteringTwigPlugins $event) use($addon) {
             $twig = $event->getTwig();
             $twig->addExtension($addon);
         });
     }
     $this->collection->put($addon->getNamespace(), $addon);
     $this->events->fire(new AddonWasRegistered($addon));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:50,代码来源:AddonIntegrator.php

示例10: registerAutoPresenter

 /**
  * Register the presenter decorator.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  *
  * @return void
  */
 public function registerAutoPresenter(Container $app)
 {
     $app->singleton('autopresenter', function (Container $app) {
         $autoPresenter = new AutoPresenter();
         $autoPresenter->register($app->make(AtomDecorator::class, ['autoPresenter' => $autoPresenter, 'app' => $app]));
         $autoPresenter->register($app->make(ArrayDecorator::class, ['autoPresenter' => $autoPresenter]));
         $autoPresenter->register($app->make(PaginatorDecorator::class, ['autoPresenter' => $autoPresenter]));
         return $autoPresenter;
     });
     $app->alias('autopresenter', AutoPresenter::class);
 }
开发者ID:ryanwinchester,项目名称:laravel-auto-presenter,代码行数:18,代码来源:AutoPresenterServiceProvider.php

示例11: registerBindings

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


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