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


PHP Container::get方法代码示例

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


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

示例1: register

 /**
  * Register this plates view provider with a Pimple container.
  *
  * @param \Pimple\Container $container
  */
 public function register(Container $container)
 {
     if (!isset($container->get('settings')['view'])) {
         throw new InvalidArgumentException('Template configuration not found');
     }
     $engine = new Plates($container->get('settings')['view'], $container->get('response'));
     $engine->loadExtension(new PlatesExtension($container->get('router'), $container->get('request')->getUri()));
     $container['view'] = $engine;
 }
开发者ID:projek-xyz,项目名称:slim-plates,代码行数:14,代码来源:PlatesProvider.php

示例2: register

 /**
  * @param ContainerInterface|Container $pimple A container instance
  *
  * @throws InvalidSettingsException
  *
  * @return Engine
  */
 public function register(Container $pimple)
 {
     $settings = $pimple->get('settings')['renderer'];
     if (is_null($settings)) {
         throw new InvalidSettingsException('Please configure the renderer settings with valid `template_path` and `template_ext` values.');
     }
     $engine = new PlatesRenderer($settings['template_path'], $settings['template_ext']);
     $engine->getEngine()->loadExtension(new PlatesSlimRouterExtension($pimple->get('router')));
     $pimple['renderer'] = $engine;
 }
开发者ID:carbontwelve,项目名称:slim-plates,代码行数:17,代码来源:PlatesViewProvider.php

示例3: register

 /**
  * Register Twig Service Provider
  *
  * @param Container $container
  */
 public function register(Container $container)
 {
     $config = $this->getConfig($container->get('settings'));
     $container['view'] = function (Container $container) use($config) {
         $engine = new Twig($config['template_path'], $config['twig']);
         // Add extensions
         $engine->addExtension(new TwigExtension($container->get('router'), $container->get('request')->getUri()));
         $engine->addExtension(new \Twig_Extension_Debug());
         return $engine;
     };
 }
开发者ID:oanhnn,项目名称:mypage,代码行数:16,代码来源:TwigServiceProvider.php

示例4: register

 /**
  * Register this content negotiator provider with a Pimple container
  *
  * @param \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $settings = $container->get('settings');
     // Overwrite default language based on setting.
     $this->default['language'] = $settings['lang']['default'];
     $container['negotiator'] = $this;
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:12,代码来源:NegotiatorProvider.php

示例5: register

 /**
  * Register this plates view provider with a Pimple container
  *
  * @param \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $settings = $container->get('settings');
     if (!isset($settings['fs'])) {
         throw new InvalidArgumentException('Filesystem configuration not found');
     }
     $container['fs'] = new Flysystem($settings['fs']);
 }
开发者ID:projek-xyz,项目名称:slim-flysystem,代码行数:13,代码来源:FlysystemProvider.php

示例6: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Container|ContainerInterface $pimple A container instance
  *
  * @return PhpRenderer
  */
 public function register(Container $pimple)
 {
     $settings = $pimple->get('settings')['logger'];
     $logger = new \Monolog\Logger($settings['name']);
     $logger->pushProcessor(new \Monolog\Processor\UidProcessor());
     $logger->pushHandler(new \Monolog\Handler\StreamHandler($settings['path'], \Monolog\Logger::DEBUG));
     $pimple['logger'] = $logger;
 }
开发者ID:carbontwelve,项目名称:slim-skeleton,代码行数:18,代码来源:LoggerProvider.php

示例7: register

 /**
  * Register this monolog provider with a Pimple container
  *
  * @param Container $container
  */
 public function register(Container $container)
 {
     $settings = $container->get('settings');
     if (!isset($settings['logger'])) {
         throw new InvalidArgumentException('Logger configuration not found');
     }
     $basename = isset($settings['basename']) ? $settings['basename'] : 'slim-app';
     $container['logger'] = new Monolog($basename, $settings['logger']);
 }
开发者ID:creasi,项目名称:slim-monolog,代码行数:14,代码来源:MonologProvider.php

示例8: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Container|ContainerInterface $pimple A container instance
  */
 public function register(Container $pimple)
 {
     $capsule = new Manager();
     $capsule->addConnection($pimple->get('settings')['database']);
     $capsule->setAsGlobal();
     $capsule->bootEloquent();
     $pimple['db'] = function () use($capsule) {
         return $capsule;
     };
 }
开发者ID:carbontwelve,项目名称:slim-skeleton,代码行数:18,代码来源:EloquentProvider.php

示例9: register

 public function register(Container $c)
 {
     $c['logger'] = function ($c) {
         $settings = $c->get('settings')['logger'];
         $logger = new Logger($settings['name']);
         $logger->pushProcessor(new UidProcessor());
         $logger->pushHandler(new StreamHandler($settings['path'], Logger::DEBUG));
         return $logger;
     };
 }
开发者ID:raistlfiren,项目名称:slim-skeleton,代码行数:10,代码来源:LoggerServiceProvider.php

示例10: register

 /**
  * Register log service provider
  *
  * @param Container $container
  */
 public function register(Container $container)
 {
     $config = $this->getConfig($container->get('settings'));
     $container['logger'] = function () use($config) {
         $logger = new Logger($config['name']);
         $logger->pushProcessor(new UidProcessor());
         $logger->pushHandler(new StreamHandler($config['path'], Logger::DEBUG));
         return $logger;
     };
 }
开发者ID:oanhnn,项目名称:mypage,代码行数:15,代码来源:LogServiceProvider.php

示例11: register

 public function register(Container $c)
 {
     $c['db'] = function ($c) {
         $settings = $c->get('settings')['pdo'];
         $queryFactory = new QueryFactory('mysql');
         $pdo = new PDOWrapper($settings['driver'] . ":host=" . $settings['host'] . ";dbname=" . $settings['dbname'], $settings['username'], $settings['password'], null, $queryFactory);
         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
         $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         return $pdo;
     };
 }
开发者ID:raistlfiren,项目名称:slim-skeleton,代码行数:12,代码来源:PDOServiceProvider.php

示例12: register

 /**
  * Register this database provider with a Pimple container
  *
  * @param \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $settings = $container->get('settings');
     if (!isset($settings['db'])) {
         throw new InvalidArgumentException('Database configuration not found');
     }
     $db = $settings['db'];
     if (!$db['dsn']) {
         $db['dsn'] = sprintf('%s:host=%s;dbname=%s;charset=%s', $db['driver'], $db['host'], $db['name'], $db['charset']);
     }
     $container['db'] = new Database($db['dsn'], $db['user'], $db['pass']);
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:17,代码来源:DatabaseProvider.php

示例13: register

 public function register(Container $app)
 {
     $app['oauth.login_route'] = '_auth_service';
     $app['oauth.callback_route'] = '_auth_service_callback';
     $app['oauth.check_route'] = '_auth_service_check';
     $app['oauth.register_routes'] = true;
     $app['oauth.services'] = array();
     $app['oauth.http_client'] = function ($app) {
         return new CurlClient();
     };
     $app['oauth.factory'] = function ($app) {
         $factory = new ServiceFactory();
         $factory->setHttpClient($app['oauth.http_client']);
         return $factory;
     };
     $app['oauth.storage'] = function ($app) {
         return new SymfonySession($app['session']);
     };
     $app['oauth.url_generator'] = function ($app) {
         return $app['url_generator'];
     };
     $app['oauth.csrf_token'] = $app->protect(function ($intention) use($app) {
         if (!isset($app['form.csrf_provider'])) {
             return null;
         }
         $tokenManagerInterface = 'Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface';
         if ($app['form.csrf_provider'] instanceof $tokenManagerInterface) {
             return strval($app['form.csrf_provider']->getToken($intention));
         }
         return $app['form.csrf_provider']->generateCsrfToken($intention);
     });
     $app['oauth'] = function ($app) {
         return new OAuthServiceRegistry($app['oauth.factory'], $app['oauth.storage'], $app['oauth.url_generator'], $app['oauth.services'], array('callback_route' => $app['oauth.callback_route']));
     };
     $app['oauth.login_paths'] = function ($app) {
         $services = array_map('strtolower', array_keys($app['oauth.services']));
         $token = $app['oauth.csrf_token']('oauth');
         return array_map(function ($service) use($app, $token) {
             return $app['url_generator']->generate($app['oauth.login_route'], array('service' => $service, '_csrf_token' => $token));
         }, array_combine($services, $services));
     };
     $app['oauth.user_info_listener'] = function ($app) {
         return new UserInfoListener($app['oauth'], $app['oauth.services']);
     };
     $app['oauth.user_provider_listener'] = function ($app) {
         return new UserProviderListener();
     };
     $app['security.authentication_listener.factory.oauth'] = $app->protect(function ($name, $options) use($app) {
         if (!isset($app['security.authentication_listener.' . $name . '.oauth'])) {
             $app['security.authentication_listener.' . $name . '.oauth'] = $app['security.authentication_listener.oauth._proto']($name, $options);
         }
         if (!isset($app['security.authentication_provider.' . $name . '.oauth'])) {
             $app['security.authentication_provider.' . $name . '.oauth'] = $app['security.authentication_provider.oauth._proto']($name);
         }
         return array('security.authentication_provider.' . $name . '.oauth', 'security.authentication_listener.' . $name . '.oauth', null, 'pre_auth');
     });
     $app['security.authentication_listener.oauth._proto'] = $app->protect(function ($name, $options) use($app) {
         return function () use($app, $name, $options) {
             $options['login_route'] = $app['oauth.login_route'];
             $options['callback_route'] = $app['oauth.callback_route'];
             $options['check_route'] = $app['oauth.check_route'];
             if ($app['oauth.register_routes']) {
                 $app->match(isset($options['login_path']) ? $options['login_path'] : '/auth/{service}', function () {
                 })->bind($options['login_route']);
                 $app->get(isset($options['callback_path']) ? $options['callback_path'] : '/auth/{service}/callback', function () {
                 })->bind($options['callback_route']);
                 $app->get(isset($options['check_path']) ? $options['check_path'] : '/auth/{service}/check', function () {
                 })->bind($options['check_route']);
             }
             if (!isset($app['security.authentication.success_handler.' . $name . '.oauth'])) {
                 $app['security.authentication.success_handler.' . $name . '.oauth'] = $app['security.authentication.success_handler._proto']($name, $options);
             }
             if (!isset($app['security.authentication.failure_handler.' . $name . '.oauth'])) {
                 $app['security.authentication.failure_handler.' . $name . '.oauth'] = $app['security.authentication.failure_handler._proto']($name, $options);
             }
             return new OAuthAuthenticationListener($app['security.token_storage'], $app['security.authentication_manager'], $app['security.session_strategy'], $app['security.http_utils'], $name, $app['oauth'], $app['security.authentication.success_handler.' . $name . '.oauth'], $app['security.authentication.failure_handler.' . $name . '.oauth'], $options, $app['logger'], $app['dispatcher'], isset($options['with_csrf']) && $options['with_csrf'] && isset($app['form.csrf_provider']) ? $app['form.csrf_provider'] : null);
         };
     });
     $app['security.authentication_provider.oauth._proto'] = $app->protect(function ($name) use($app) {
         return function () use($app, $name) {
             return new OAuthAuthenticationProvider($app['security.user_provider.' . $name], $app['security.user_checker'], $name, $app['dispatcher']);
         };
     });
 }
开发者ID:akarmazyn,项目名称:silex-oauth,代码行数:84,代码来源:OAuthServiceProvider.php

示例14:

 function __construct(Container $container, $session)
 {
     $this->container = $container;
     $this->session = $container->get($session);
 }
开发者ID:php-genie,项目名称:genie,代码行数:5,代码来源:Manger.php


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