當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Container::before方法代碼示例

本文整理匯總了PHP中Pimple\Container::before方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::before方法的具體用法?PHP Container::before怎麽用?PHP Container::before使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimple\Container的用法示例。


在下文中一共展示了Container::before方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 public function register(Container $app)
 {
     $app['menu_manager'] = function ($app) {
         return new MenuManager($app, $app['menu']);
     };
     $app['menu_manager.security'] = function ($app) {
         return new MenuSecurityService($app);
     };
     $app['twig.loader.filesystem'] = $app->extend('twig.loader.filesystem', function ($filesystem, $app) {
         $filesystem->addPath(__DIR__ . '/../Resource/views', 'MenuManager');
         return $filesystem;
     });
     $app['twig'] = $app->extend('twig', function ($twig, $app) {
         $twig->addFunction(new \Twig_SimpleFunction('menu', function ($which = 'main', Item $item = null, $paramList = [], $activeOnly = false) use($app) {
             return $app['menu_manager']->render($which, $item, $paramList, $activeOnly);
         }));
         $twig->addFunction(new \Twig_SimpleFunction('breadcrumb', function ($paramList = []) use($app) {
             return $app['menu_manager']->renderBreadcrumb($paramList);
         }));
         return $twig;
     });
     // Current route name
     $app->before(function (Request $request) use($app) {
         $app['menu_manager']->setCurrentRoute($request->get('_route'));
     });
 }
開發者ID:Plumillon,項目名稱:MenuManager,代碼行數:26,代碼來源:MenuServiceProvider.php

示例2: register

 public function register(Container $app)
 {
     $app->before(function (Request $request) {
         if ($this->isRequestTransformable($request)) {
             $transformedRequest = $this->transformContent($request->getContent());
             $request->request->replace($transformedRequest);
         }
     });
 }
開發者ID:jacksongomesbr,項目名稱:livro-web-codigo-fonte,代碼行數:9,代碼來源:AngularPostRequestServiceProvider.php

示例3: register

 public function register(Container $app)
 {
     $app->before(function (Request $req) use($app) {
         $correctUser = $app['basic_auth.user'];
         $correctPasswordMd5 = $app['basic_auth.password_md5'];
         if (isset($app['basic_auth.pattern'])) {
             $pattern = $app['basic_auth.pattern'];
             $uri = $req->getRequestUri();
             if (!preg_match("|{$pattern}|u", $uri)) {
                 return;
             }
         }
         $realm = 'Secured';
         if (isset($app['basic_auth.realm'])) {
             $realm = $app['basic_auth.realm'];
         }
         $authUser = $req->server->get('PHP_AUTH_USER');
         $authPw = $req->server->get('PHP_AUTH_PW');
         if ($authUser === $correctUser && md5($authPw) === $correctPasswordMd5) {
             return;
         }
         throw new HttpException(Response::HTTP_UNAUTHORIZED, null, null, ['WWW-Authenticate' => 'Basic realm="' . $realm . '"']);
     });
 }
開發者ID:10mado,項目名稱:silexcane,代碼行數:24,代碼來源:BasicAuthServiceProvider.php


注:本文中的Pimple\Container::before方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。