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


PHP Slim::map方法代码示例

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


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

示例1: appendRoute

 protected function appendRoute($routes, $prefix = '')
 {
     $bootstrap = $this;
     foreach ($routes as $item) {
         if (is_object($item)) {
             /* @var $item MvcContext */
             $context = $item;
             $context->app = $this;
             $context->rewriteBase = $this->rewriteBase;
             if (!is_array($item->path)) {
                 $item->path = array($item->path);
             }
             foreach ($item->path as $path) {
                 $map = $this->slim->map($prefix . $path, function () use($bootstrap, $context) {
                     $bootstrap->executeAction($context, func_get_args());
                 });
                 //via method
                 $methods = array();
                 if ($context->method == '*') {
                     $methods = array('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH');
                 } else {
                     $methods = explode(',', strtoupper($context->method));
                 }
                 call_user_func_array(array($map, 'via'), $methods);
             }
         } else {
             if (!is_array($item->path)) {
                 $item->path = array($item->path);
             }
             foreach ($item->path as $path) {
                 $this->appendRoute($item, $prefix . $path);
             }
         }
     }
 }
开发者ID:hopitio,项目名称:framework,代码行数:35,代码来源:Bootstrap.php

示例2: defineRoutes

 protected function defineRoutes(\Slim\Slim $app)
 {
     // named routes first; should an event pick the same name then at least our actions take precedence
     $app->get('/event', array($this, 'index'))->name("events-index");
     $app->get('/event/pending', array($this, 'pending'))->name("events-pending");
     $app->map('/event/submit', array($this, 'submit'))->via('GET', 'POST')->name('event-submit');
     $app->get('/event/callforpapers', array($this, 'callForPapers'))->name('event-call-for-papers');
     $app->get('/event/:friendly_name', array($this, 'eventDefault'))->name("event-default");
     $app->get('/event/:friendly_name/details', array($this, 'details'))->name("event-detail");
     $app->get('/event/:friendly_name/comments', array($this, 'comments'))->name("event-comments");
     $app->get('/event/:friendly_name/comments/:comment_hash/report', array($this, 'reportComment'))->name("event-comments-reported");
     $app->get('/event/:friendly_name/schedule', array($this, 'schedule'))->name("event-schedule");
     $app->get('/event/:friendly_name/schedule/list', array($this, 'scheduleList'))->name("event-schedule-list");
     $app->get('/event/:friendly_name/schedule/grid', array($this, 'scheduleGrid'))->name("event-schedule-grid");
     $app->get('/event/:friendly_name/talk-comments', array($this, 'talkComments'))->name("event-talk-comments");
     $app->post('/event/:friendly_name/add-comment', array($this, 'addComment'))->name('event-add-comment');
     $app->map('/event/:friendly_name/edit', array($this, 'edit'))->via('GET', 'POST')->name('event-edit');
     $app->get('/e/:stub', array($this, 'quicklink'))->name("event-quicklink");
     $app->get('/event/xhr-attend/:friendly_name', array($this, 'xhrAttend'));
     $app->get('/event/xhr-unattend/:friendly_name', array($this, 'xhrUnattend'));
     $app->get('/event/attend/:friendly_name', array($this, 'attend'))->name("event-attend");
     $app->get('/event/unattend/:friendly_name', array($this, 'unattend'))->name("event-unattend");
     $app->post('/event/action-pending-event/:friendly_name', array($this, 'actionPendingEvent'))->name("event-action-pending");
     $app->get('/event/view/:eventId(/:extra+)', array($this, 'redirectFromId'))->name('event-redirect-from-id')->conditions(array('eventId' => '\\d+'));
 }
开发者ID:xsist10,项目名称:joindin-web2,代码行数:25,代码来源:EventController.php

示例3: addRouteDefinitions

 /**
  * Adds a backend routes
  * @param $appInstance
  * @return void
  */
 public static function addRouteDefinitions(Slim $appInstance)
 {
     $appInstance->group('/admin', function () use($appInstance) {
         $appInstance->get('/', function () {
             print '<h1>A Simple Backend</h1>';
         });
         $appInstance->map("/chpass", function () use($appInstance) {
             if (EMA_ADMIN_CHPASS) {
                 AdminPasswordChange_controller::process();
             } else {
                 $appInstance->pass();
             }
         })->via('GET', 'POST');
         $appInstance->map("/update", function () use($appInstance) {
             ClassAndMethodsDispatcher::updateGPMethods();
         })->via('GET', 'POST');
         $appInstance->post("/login", function () use($appInstance) {
             $appInstance->response->headers->set('Cache-Control', 'no-store');
             if (isset($_POST['username']) && is_string($_POST['username']) && (isset($_POST['password']) && is_string($_POST['password']))) {
                 try {
                     try {
                         $user = new UserAuth();
                     } catch (SessionExpired $e) {
                         $user = new UserAuth();
                     }
                     $user->userLogin($_POST['username'], $_POST['password']);
                     if (!$user->isAdmin()) {
                         $user->logout();
                         throw new LoginIncorrect('You are not allowed to login here');
                     }
                     $appInstance->response->headers->set('Content-Type', 'application/json');
                     print json_encode($user->getSessionAuthData());
                 } catch (LoginIncorrect $e) {
                     $appInstance->response->headers->set('Content-Type', 'text/plain');
                     $appInstance->response->setStatus(400);
                     print $e->getMessage();
                 }
             } else {
                 $appInstance->response->headers->set('Content-Type', 'text/plain');
                 $appInstance->response->setStatus(400);
                 print 'Bad request';
             }
         });
         $appInstance->map('/logout', function () use($appInstance) {
             try {
                 $user = new UserAuth();
                 if ($user->isUserLoggedInSimple()) {
                     $user->logout();
                 }
             } catch (SessionExpired $e) {
             }
         })->via('GET', 'POST');
     });
 }
开发者ID:indiwine,项目名称:EMA-engine,代码行数:59,代码来源:BackendRouting.php

示例4: addRoutes

 /**
  * @param string $name
  * @param array $extraRoutes
  */
 public function addRoutes($name, array $extraRoutes = [])
 {
     $cb = [$this, $name];
     $this->app->map("/{$name}", $cb)->via('GET', 'POST');
     $this->app->map("/{$name}/:action", $cb)->via('GET', 'POST');
     $this->app->map("/{$name}/:action/:params+", $cb)->via('GET', 'POST');
     if (!empty($extraRoutes)) {
         foreach ($extraRoutes as $route) {
             $this->app->map($route, $cb)->via('GET', 'POST');
         }
     }
 }
开发者ID:maxdmyers,项目名称:dashbrew,代码行数:16,代码来源:ControllerCollection.php

示例5: defineRoutes

 protected function defineRoutes(\Slim\Slim $app)
 {
     $app->get('/', array($this, 'index'));
     $app->get('/apps', array($this, 'apps'))->name('apps');
     $app->get('/about', array($this, 'about'))->name('about');
     $app->map('/contact', array($this, 'contact'))->via('GET', 'POST')->name('contact');
     $app->get('/not-allowed', array($this, 'notAllowed'))->name('not-allowed');
 }
开发者ID:robth82,项目名称:joindin-web2,代码行数:8,代码来源:ApplicationController.php

示例6: defineRoutes

 protected function defineRoutes(\Slim\Slim $app)
 {
     $app->get('/event/:eventSlug/:talkSlug', array($this, 'index'))->name('talk');
     $app->map('/event/:eventSlug/:talkSlug/edit', array($this, 'editTalk'))->via('GET', 'POST')->name('talk-edit');
     $app->post('/event/:eventSlug/:talkSlug/star', array($this, 'star'))->name('talk-star');
     $app->get('/talk/:talkStub', array($this, 'quick'))->name('talk-quicklink');
     $app->get('/event/:eventSlug/:talkSlug/comments/:commentHash/report', array($this, 'reportComment'))->name('talk-report-comment');
     $app->post('/event/:eventSlug/:talkSlug/add-comment', array($this, 'addComment'))->name('talk-add-comment');
     $app->get('/:talkId', array($this, 'quickById'))->name('talk-quick-by-id')->conditions(array('talkId' => '\\d+'));
     $app->get('/talk/view/:talkId', array($this, 'quickById'))->name('talk-by-id-web1')->conditions(array('talkId' => '\\d+'));
 }
开发者ID:railto,项目名称:joindin-web2,代码行数:11,代码来源:TalkController.php

示例7: defineRoutes

 protected function defineRoutes(\Slim\Slim $app)
 {
     // named routes first; should an event pick the same name then at least our actions take precedence
     $app->get('/event', array($this, 'index'))->name("events-index");
     $app->get('/event/pending', array($this, 'pending'))->name("events-pending");
     $app->map('/event/submit', array($this, 'submit'))->via('GET', 'POST')->name('event-submit');
     $app->get('/event/callforpapers', array($this, 'callForPapers'))->name('event-call-for-papers');
     $app->get('/event/:friendly_name', array($this, 'details'))->name("event-detail");
     $app->get('/event/:friendly_name/comments', array($this, 'comments'))->name("event-comments");
     $app->get('/event/:friendly_name/schedule', array($this, 'schedule'))->name("event-schedule");
     $app->get('/event/:friendly_name/talk-comments', array($this, 'talkComments'))->name("event-talk-comments");
     $app->post('/event/:friendly_name/add-comment', array($this, 'addComment'))->name('event-add-comment');
     $app->map('/event/:friendly_name/edit', array($this, 'edit'))->via('GET', 'POST')->name('event-edit');
     $app->get('/e/:stub', array($this, 'quicklink'))->name("event-quicklink");
     $app->get('/event/xhr-attend/:friendly_name', array($this, 'xhrAttend'));
     $app->get('/event/xhr-unattend/:friendly_name', array($this, 'xhrUnattend'));
     $app->get('/event/attend/:friendly_name', array($this, 'attend'))->name("event-attend");
     $app->get('/event/unattend/:friendly_name', array($this, 'unattend'))->name("event-unattend");
     $app->post('/event/action-pending-event/:friendly_name', array($this, 'actionPendingEvent'))->name("event-action-pending");
 }
开发者ID:shaunmza,项目名称:joindin-web2,代码行数:20,代码来源:EventController.php

示例8: addRouteDefinitions

 /**
  * This methods will be called at application startup
  * @param $appInstance
  * @return void
  */
 public static function addRouteDefinitions(Slim $appInstance)
 {
     $appInstance->group('/nats', function () use($appInstance) {
         $appInstance->map('/users', function () use($appInstance) {
             try {
                 $inst = new cNatsMembersPostback();
                 print 'OK|' . $inst->run();
             } catch (InputError $e) {
                 print 'NOTOK|' . $e->getMessage();
             } catch (FatalError $e) {
                 print 'ERROR|' . $e->getMessage();
             }
         })->via('GET', 'POST');
     });
 }
开发者ID:indiwine,项目名称:EMA-engine,代码行数:20,代码来源:NatsPostbackRouting.php

示例9: install

 /**
  * 
  * @return Routes
  */
 public function install(\Slim\Slim $app)
 {
     foreach ($this->routes as $route) {
         $slimRoute = $app->map($route->route(), function () use($route) {
             // parametry akcji/metody
             $params = array_merge($route->defaults(), func_get_args());
             // kontroler
             $controller = false !== strpos('\\', $route->controller()) ? $route->controller() : '\\ZPP\\Application\\Controller\\' . $route->controller();
             // jeśli istnieje
             if (class_exists($controller)) {
                 $controllerObject = new $controller();
                 return call_user_func_array([$controllerObject, $route->action()], $params);
             } else {
                 throw new \Exception('Cannot find controller ' . $controller);
             }
         })->name($route->name());
         call_user_func_array([$slimRoute, 'via'], $route->methods());
     }
 }
开发者ID:mzieba,项目名称:zpp-slim-basic,代码行数:23,代码来源:Routes.php

示例10: defineRoutes

 /**
  * Routes implemented by this class
  *
  * @param \Slim $app Slim application instance
  *
  * @return void
  */
 protected function defineRoutes(\Slim\Slim $app)
 {
     $app->get('/user/logout', array($this, 'logout'))->name('user-logout');
     $app->map('/user/login', array($this, 'login'))->via('GET', 'POST')->name('user-login');
     $app->map('/user/register', array($this, 'register'))->via('GET', 'POST')->name('user-register');
     $app->get('/user/verification', array($this, 'verification'))->name('user-verification');
     $app->map('/user/resend-verification', array($this, 'resendVerification'))->via('GET', 'POST')->name('user-resend-verification');
     $app->map('/user/username-reminder', array($this, 'remindUsername'))->via('GET', 'POST')->name('user-username-reminder');
     $app->map('/user/password-reset', array($this, 'resetPassword'))->via('GET', 'POST')->name('user-password-reset');
     $app->map('/user/new-password', array($this, 'newPassword'))->via('GET', 'POST')->name('user-new-password');
     $app->get('/user/twitter-login', array($this, 'loginWithTwitter'))->name('twitter-login');
     $app->get('/user/twitter-access', array($this, 'accessTokenFromTwitter'))->name('twitter-callback');
     $app->get('/user/:username', array($this, 'profile'))->name('user-profile');
     $app->get('/user/:username/talks', array($this, 'profileTalks'))->name('user-profile-talks');
     $app->get('/user/:username/events', array($this, 'profileEvents'))->name('user-profile-events');
     $app->get('/user/:username/hosted', array($this, 'profileHosted'))->name('user-profile-hosted');
     $app->get('/user/:username/comments', array($this, 'profileComments'))->name('user-profile-comments');
     $app->map('/user/:username/edit', array($this, 'profileEdit'))->via('GET', 'POST')->name('user-profile-edit');
 }
开发者ID:shaunmza,项目名称:joindin-web2,代码行数:26,代码来源:UserController.php

示例11: load_slim

 public function load_slim()
 {
     $slim = new Slim($this->slim_settings);
     foreach ($this->routes as $old_route) {
         $name = isset($old_route[self::SLIM_NAME]) && is_string($old_route[self::SLIM_NAME]) ? $old_route[self::SLIM_NAME] : null;
         $pattern = isset($old_route[self::SLIM_PATTERN]) && is_string($old_route[self::SLIM_PATTERN]) ? $old_route[self::SLIM_PATTERN] : null;
         $methods = isset($old_route[self::SLIM_METHODS]) && is_array($old_route[self::SLIM_METHODS]) ? $old_route[self::SLIM_METHODS] : null;
         $resolver = isset($old_route[self::SLIM_RESOLVER]) && is_callable($old_route[self::SLIM_RESOLVER]) ? $old_route[self::SLIM_RESOLVER] : null;
         $auth = isset($old_route[self::SLIM_AUTH]) && is_string(self::SLIM_AUTH) ? $old_route[self::SLIM_AUTH] : null;
         $conditions = isset($old_route[self::SLIM_CONDS]) && is_array($old_route[self::SLIM_CONDS]) ? $old_route[self::SLIM_CONDS] : null;
         if ($name == null || $pattern == null || $methods == null || $resolver == null || $auth == null) {
             continue;
         }
         $route = $slim->map($pattern, Authorization::hook($auth), $resolver);
         $route->via($methods);
         $route->name($name);
         if ($conditions != null) {
             $route->conditions($conditions);
         }
     }
     $slim->run();
 }
开发者ID:rulosan,项目名称:secprog,代码行数:22,代码来源:Application.php

示例12: addRouteDefinitions

 /**
  * This methods will be called at application startup
  * @param $appInstance
  * @return void
  * @throws \Exception
  */
 public static function addRouteDefinitions(Slim $appInstance)
 {
     $appInstance->map('/protected-storage/:inst/:id/:accessMethod/:path+', function ($inst, $id, $accessMethod, $path) use($appInstance) {
         if (!in_array($accessMethod, cProtectedStorage::$allowedAccessMethods, true)) {
             $appInstance->halt(400, 'Invalid request');
         }
         $fileName = array_pop($path);
         $rel = '';
         foreach ($path as $value) {
             $rel .= $value . '/';
         }
         $rel .= $fileName;
         $user = null;
         if ($accessMethod === 'private') {
             try {
                 $user = new MembersAuth();
                 $user->isUserLoggedIn();
             } catch (LoginExceptions $e) {
                 $appInstance->halt(401, 'Unauthorized');
             }
         }
         $fullPath = $inst . '/' . $id . '/' . $accessMethod . '/' . $rel;
         $controller = new cProtectedStorage($inst, $id, $accessMethod, $rel);
         if ($controller->isCorrectPath($fullPath)) {
             $appInstance->etag(md5($fullPath));
             $appInstance->expires('+1 week');
             $headers = $controller->outputFile();
             if (array_key_exists('download', $_REQUEST)) {
                 $headers['Content-Type'] = 'application/octet-stream';
             }
             foreach ($headers as $key => $value) {
                 $appInstance->response->headers->set($key, $value);
             }
         } else {
             $appInstance->notFound();
         }
     })->via('GET', 'POST');
 }
开发者ID:indiwine,项目名称:EMA-engine,代码行数:44,代码来源:ProtectedStorageRouting.php

示例13: addRouteDefinitions

 /**
  * This methods will be called at application startup
  * @param $appInstance
  * @return void
  */
 public static function addRouteDefinitions(Slim $appInstance)
 {
     $appInstance->get('/', function () {
         print '<h1>A simple frontend</h1>';
     });
     $appInstance->post("/login", function () use($appInstance) {
         $appInstance->response->headers->set('Cache-Control', 'no-store');
         if (isset($_POST['username']) && is_string($_POST['username']) && (isset($_POST['password']) && is_string($_POST['password']))) {
             try {
                 try {
                     $user = new MembersAuth();
                 } catch (SessionExpired $e) {
                     $user = new MembersAuth();
                 }
                 $user->userLogin($_POST['username'], $_POST['password']);
                 $appInstance->response->headers->set('Content-Type', 'application/json');
                 print json_encode($user->getSessionAuthData());
             } catch (LoginIncorrect $e) {
                 $appInstance->response->headers->set('Content-Type', 'text/plain');
                 $appInstance->response->setStatus(400);
                 print $e->getMessage();
             }
         } else {
             $appInstance->response->headers->set('Content-Type', 'text/plain');
             $appInstance->response->setStatus(400);
             print 'Bad request';
         }
     });
     $appInstance->map('/logout', function () use($appInstance) {
         try {
             $user = new MembersAuth();
             if ($user->isUserLoggedInSimple()) {
                 $user->logout();
             }
         } catch (SessionExpired $e) {
         }
     })->via('GET', 'POST');
 }
开发者ID:indiwine,项目名称:EMA-engine,代码行数:43,代码来源:FrontendRouting.php

示例14: add


//.........这里部分代码省略.........
             // Load Bean first
             $this->loadBean($id);
             // ID must be hidden
             $this->field("id")->hide();
             if ($this->configFunction != null) {
                 $function = $this->configFunction;
                 $result = $function();
                 if ($result === false) {
                     return;
                 }
             }
             if ($customCRUDFunction != null) {
                 $result = $customCRUDFunction($p1, $p2, $p3, $p4, $p5);
                 if ($result === false) {
                     return;
                 }
             }
             if ($this->editFunction != null) {
                 $editFunction = $this->editFunction;
                 $result = $editFunction($id, $p1, $p2, $p3, $p4, $p5);
                 if ($result === false) {
                     return;
                 }
             }
             // If user show the ID field, force set it to readonly
             $this->field("id")->setReadOnly(true);
             if ($this->isEnabledEdit()) {
                 $this->renderEditView();
             }
         });
         /*
          * Export Excel
          */
         $this->slim->map("/export(/:p1(/:p2(/:p3(/:p4(/:p5)))))", function ($p1 = null, $p2 = null, $p3 = null, $p4 = null, $p5 = null) use($routeName, $customCRUDFunction, $tableName) {
             // MUST INIT FIRST
             $this->init($tableName, $routeName, $p1, $p2, $p3, $p4, $p5);
             if ($this->configFunction != null) {
                 $function = $this->configFunction;
                 $result = $function();
                 if ($result === false) {
                     return;
                 }
             }
             if ($customCRUDFunction != null) {
                 $result = $customCRUDFunction($p1, $p2, $p3, $p4, $p5);
                 if ($result === false) {
                     return;
                 }
             }
             if ($this->listviewFunction != null) {
                 $listviewFunction = $this->listviewFunction;
                 $result = $listviewFunction($p1, $p2, $p3, $p4, $p5);
                 if ($result === false) {
                     return;
                 }
             }
             if ($this->exportFunction != null) {
                 $exportFunction = $this->exportFunction;
                 $result = $exportFunction($p1, $p2, $p3, $p4, $p5);
                 if ($result === false) {
                     return;
                 }
             }
             // TODO: isEnabledExport();
             $this->renderExcel();
         })->via('GET', 'POST');
开发者ID:louislam,项目名称:louislam-crud,代码行数:67,代码来源:SlimLouisCRUD.php

示例15: register

 /**
  * Register this route with the given Slim application and OAuth2 server
  *
  * @param Slim   $slim     The slim framework application instance.
  * @param string $template The template for /receive-code
  *
  * @return void
  */
 public static function register(Slim $slim, $template = 'receive-code.phtml')
 {
     $slim->map(self::ROUTE, new self($slim, $template))->via('GET', 'POST')->name('receive-code');
 }
开发者ID:tularamaurya,项目名称:slim-oauth2-routes,代码行数:12,代码来源:ReceiveCode.php


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