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


PHP Container::match方法代码示例

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


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

示例1: register

 public function register(Container $app)
 {
     $app['maintenance.enabled'] = false;
     if ($this->isMaintenanceMode) {
         $app['maintenance.enabled'] = true;
         if ($this->htmlFile) {
             $app['maintenance.html'] = file_get_contents($this->htmlFile);
             $app->match('/{path}', function () use($app) {
                 return new Response($app['maintenance.html'], 503);
             })->assert('path', '.*');
         } elseif (isset($app['twig']) && $this->twigTemplate) {
             $app['maintenance.twig_template'] = $this->twigTemplate;
             $app->match('/{path}', function () use($app) {
                 $response = new Response();
                 $response->setStatusCode(503);
                 $response->setContent($app['twig']->render($app['maintenance.twig_template']));
                 return $response;
             })->assert('path', '.*');
         } else {
             $app->match('/{path}', function () use($app) {
                 return $app->abort(503);
             })->assert('path', '.*');
         }
     }
 }
开发者ID:10mado,项目名称:silexcane,代码行数:25,代码来源:MaintenanceWindowServiceProvider.php

示例2: register

 public function register(\Pimple\Container $app)
 {
     $app['steam_auth'] = function () use($app) {
         $openid = new \LightOpenID($app['steam_auth.host']);
         $openid->identity = 'http://steamcommunity.com/openid';
         return $openid;
     };
     $app['security.authentication_listener.factory.steam_auth'] = $app->protect(function ($name, $options) use($app) {
         $options = array_replace_recursive(array('check_path' => '/login/steamauthcheck'), $options);
         if (!isset($app['security.authentication.success_handler.' . $name])) {
             $app['security.authentication.success_handler.' . $name] = $app['security.authentication.success_handler._proto']($name, $options);
         }
         if (!isset($app['security.authentication.failure_handler.' . $name])) {
             $app['security.authentication.failure_handler.' . $name] = $app['security.authentication.failure_handler._proto']($name, $options);
         }
         // define the authentication provider object
         if (!isset($app['security.authentication_provider.' . $name . '.steam_auth'])) {
             $app['security.authentication_provider.' . $name . '.steam_auth'] = function () use($app, $name) {
                 return new SteamAuthProvider($app['security.user_provider.' . $name]);
             };
         }
         // define the authentication listener object
         if (!isset($app['security.authentication_listener.' . $name . '.steam_auth'])) {
             $app['security.authentication_listener.' . $name . '.steam_auth'] = function () use($app, $name, $options) {
                 return new SteamAuthListener($app['steam_auth'], $app['security.token_storage'], $app['security.authentication_manager'], isset($app['security.session_strategy.' . $name]) ? $app['security.session_strategy.' . $name] : $app['security.session_strategy'], $app['security.http_utils'], $name, $app['security.authentication.success_handler.' . $name], $app['security.authentication.failure_handler.' . $name], $options, $app['logger'], $app['dispatcher']);
             };
         }
         $bindName = "steam_auth_{$name}_";
         $app->match($options['check_path'], function () {
         })->bind($bindName . 'check');
         $app->match('/login', function () use($app, $bindName) {
             return $app->redirect($app['url_generator']->generate($bindName . 'check'));
         });
         return array('security.authentication_provider.' . $name . '.steam_auth', 'security.authentication_listener.' . $name . '.steam_auth', null, 'pre_auth');
     });
 }
开发者ID:rafalniewinski,项目名称:silex-steamauth,代码行数:36,代码来源:SteamAuthServiceProvider.php

示例3: addRoute

 /**
  * Adds a route, a given route-name (for named routes) and all of its methods
  *
  * @param Container $app
  * @param array $route
  * @throws InvalidArgumentException
  */
 public function addRoute(Container $app, array $route, $name = '')
 {
     if (isset($route['method']) && is_string($route['method'])) {
         $route['method'] = array($route['method']);
     }
     $this->validateRoute($route);
     if (array_key_exists('name', $route)) {
         $name = $route['name'];
     }
     $controller = $app->match($route['pattern'], $route['controller'])->bind($this->sanitizeRouteName($name))->method(join('|', array_map('strtoupper', $route['method'])));
     $supportedProperties = array('value', 'assert', 'convert', 'before', 'after');
     foreach ($supportedProperties as $property) {
         if (isset($route[$property])) {
             $this->addActions($controller, $route[$property], $property);
         }
     }
     if (isset($route['scheme'])) {
         if ('https' === $route['scheme']) {
             $controller->requireHttps();
         }
     }
 }
开发者ID:marcojanssen,项目名称:silex-routing-service-provider,代码行数:29,代码来源:RoutingServiceProvider.php

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


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