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


PHP Silex\ControllerCollection类代码示例

本文整理汇总了PHP中Silex\ControllerCollection的典型用法代码示例。如果您正苦于以下问题:PHP ControllerCollection类的具体用法?PHP ControllerCollection怎么用?PHP ControllerCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: connect

 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     // *******
     // ** Signup member
     // *******
     $controllers->get('signup.html', function () use($app) {
         $form = $app['form.factory']->create(new \Aperophp\Form\Signup());
         return $app['twig']->render('member/signup.html.twig', array('form' => $form->createView()));
     })->bind('_signupmember');
     // *******
     // *******
     // ** Create member
     // *******
     $controllers->post('create.html', function (Request $request) use($app) {
         $form = $app['form.factory']->create(new \Aperophp\Form\Signup());
         $form->bindRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             // TODO save member in database.
             var_dump($data);
             die;
         }
         return $app['twig']->render('member/signup.html.twig', array('form' => $form->createView()));
     })->bind('_createmember');
     // *******
     return $controllers;
 }
开发者ID:nmariani,项目名称:aperophp,代码行数:28,代码来源:Member.php

示例2: addRoutes

 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/changelog', 'changeOverview')->bind('changelog');
     $c->get('/changelog/{contenttype}/{contentid}/{id}', 'changeRecord')->assert('id', '\\d*')->bind('changelogrecordsingle');
     $c->get('/changelog/{contenttype}/{contentid}', 'changeRecordListing')->value('contentid', '0')->value('contenttype', '')->bind('changelogrecordall');
     $c->get('/systemlog', 'systemOverview')->bind('systemlog');
 }
开发者ID:d-m-,项目名称:bolt,代码行数:7,代码来源:Log.php

示例3: addRoutes

 protected function addRoutes(ControllerCollection $c)
 {
     $c->get('/login', 'getLogin')->bind('login');
     $c->post('/login', 'postLogin')->bind('postLogin');
     $c->match('/logout', 'logout')->bind('logout');
     $c->get('/resetpassword', 'resetPassword')->bind('resetpassword');
 }
开发者ID:nuffer,项目名称:bolt,代码行数:7,代码来源:Authentication.php

示例4: connect

 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $supervisor = new API();
     $servers = (include __DIR__ . '/../../config.php');
     foreach (array_keys($servers) as $server_id) {
         $servers[$server_id]['id'] = $server_id;
     }
     $controllers->get('/list.{_format}', function ($_format) use($supervisor, $app, $servers) {
         if ($_format == 'json') {
             return $app->json($servers);
         } else {
             // use a closure to avoid leaking any vars into the template that we don't explicitly want
             return call_user_func(function () use($app) {
                 $url_root = $app['url_generator']->generate('home');
                 ob_start();
                 ob_implicit_flush(false);
                 include __DIR__ . '/../../views/supervisorui.html.php';
                 return ob_get_clean();
             });
         }
     })->bind('server_list')->value('_format', 'html');
     $controllers->get('/details/{server_id}', function ($server_id) use($supervisor, $app, $servers) {
         $server_ip = $servers[$server_id]['ip'];
         $details = array_merge(array('version' => $supervisor->getSupervisorVersion('127.0.0.1'), 'pid' => $supervisor->getPID('127.0.0.1')), $supervisor->getState('127.0.0.1'), $servers[$server_id]);
         return $app->json($details);
     });
     return $controllers;
 }
开发者ID:jbinfo,项目名称:supervisorui,代码行数:29,代码来源:ServerControllerProvider.php

示例5: addRoutes

 protected function addRoutes(ControllerCollection $c)
 {
     $c->method('GET|POST');
     $c->match('/editcontent/{contenttypeslug}/{id}', 'edit')->bind('editcontent')->assert('id', '\\d*')->value('id', '');
     $c->get('/overview/{contenttypeslug}', 'overview')->bind('overview');
     $c->get('/relatedto/{contenttypeslug}/{id}', 'related')->bind('relatedto')->assert('id', '\\d*');
 }
开发者ID:atiarda,项目名称:bolt,代码行数:7,代码来源:Records.php

示例6: addRoutes

 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/tokens', array($this, 'indexAction'))->bind('user_tokens');
     $controllers->get('/tokens/new', array($this, 'newAction'))->bind('user_tokens_new');
     $controllers->post('/tokens/new', array($this, 'newAction'))->bind('user_tokens_new_process');
     $controllers->post('/tokens/{token}/delete', array($this, 'deleteAction'))->bind('user_tokens_delete');
 }
开发者ID:emiliand,项目名称:rest,代码行数:7,代码来源:TokenController.php

示例7: addRoutes

 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/users/new', array($this, 'newAction'))->bind('user_new');
     $controllers->post('/users/new', array($this, 'handleNewAction'))->bind('user_new_handle');
     $controllers->get('/users/choose', array($this, 'chooseAction'))->bind('user_choose');
     $controllers->get('/users/{name}', array($this, 'showAction'))->bind('user_show');
 }
开发者ID:rllmwm,项目名称:forbiddencat,代码行数:7,代码来源:UserController.php

示例8: addRoutes

 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->post('/key', [$this, 'create']);
     $controllers->get('/key/{id}', [$this, 'show']);
     $controllers->put('/key/{id}', [$this, 'update']);
     $controllers->delete('/key/{id}', [$this, 'delete']);
 }
开发者ID:powertim,项目名称:teampass-api,代码行数:7,代码来源:KeyController.php

示例9: connect

 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $controllers->get('auth', function () use($app) {
         if ($app['session']->has($app['config']['prefix'] . 'authed-user')) {
             return $app->redirect('/');
         }
         return $app['twig']->render('PT/pages/authenticate.html', array('auth_path' => $app['uri']->generate('authenticate')));
     })->bind('authenticate');
     $controllers->post('auth', function () use($app) {
         if ($app['request']->get('username') === $app['config']['authenticate']['username'] && $app['request']->get('password') === $app['config']['authenticate']['password']) {
             $userHash = $userHash = sha1($app['config']['authenticate']['username'] . $app['config']['authenticate']['password']);
             $currentUser = $app['session']->set($app['config']['prefix'] . 'authed-user', $userHash);
             return $app->redirect('/');
         } else {
             $app['session']->setFlash('error', 'error');
             $app['session']->remove($app['config']['prefix'] . 'authed-user');
             return $app->redirect($app['uri']->generate('authenticate'));
         }
     })->bind('do_authenticate');
     $controllers->get('deauth', function ($result) use($app) {
         $app['session']->remove($app['config']['prefix'] . 'authed-user');
         return $app->redirect($app['uri']->generate('authenticate'));
     })->value('result', null)->bind('de_authenticate');
     return $controllers;
 }
开发者ID:netcon-source,项目名称:prontotype,代码行数:26,代码来源:SystemController.php

示例10: addRoutes

 protected function addRoutes(ControllerCollection $controllers)
 {
     $controllers->get('/password/generate', [$this, 'generatePassword']);
     $controllers->post('/password/generate', [$this, 'generatePassword']);
     $controllers->get('/password/complication', [$this, 'complicationPassword']);
     $controllers->get('/secret', [$this, 'secret']);
 }
开发者ID:suniltantry,项目名称:teampass-api,代码行数:7,代码来源:SystemController.php

示例11: connect

 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $controllers->match('/{slug}', function (Application $app, Request $request, $username) {
         return $this->getProcessor($request)->execute()->getResponse();
     });
     return $controllers;
 }
开发者ID:nlegoff,项目名称:statme,代码行数:8,代码来源:User.php

示例12: process

 /**
  * Register the method $controllerName as controller for the given method and uri.
  *
  * @param \Silex\ControllerCollection $cc
  * @param string                      $controllerName Fully qualified method name of the controller
  * @return \Silex\Controller
  */
 public function process(ControllerCollection $cc, $controllerName)
 {
     $controller = $cc->match($this->uri, $controllerName);
     if ('MATCH' != ($method = strtoupper($this->method))) {
         // limit to configured method(s)
         $controller = $controller->method($method);
     }
     return $controller;
 }
开发者ID:jsmith07,项目名称:silex-annotation-provider,代码行数:16,代码来源:Request.php

示例13: addRoutes

 protected function addRoutes(ControllerCollection $c)
 {
     $c->match('/file/edit/{namespace}/{file}', 'edit')->assert('file', '.+')->assert('namespace', '[^/]+')->value('namespace', 'files')->bind('fileedit')->after(function (Request $request, Response $response) {
         if ($request->isMethod('POST')) {
             $response->headers->set('X-XSS-Protection', '0');
         }
     });
     $c->match('/files/{namespace}/{path}', 'manage')->assert('namespace', '[^/]+')->assert('path', '.*')->value('namespace', 'files')->value('path', '')->bind('files');
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:9,代码来源:FileManager.php

示例14: testConflictingRouteNames

 public function testConflictingRouteNames()
 {
     $controllers = new ControllerCollection();
     $mountedRootController = new Controller(new Route('/'));
     $controllers->add($mountedRootController);
     $mainRootController = new Controller(new Route('/'));
     $mainRootController->bindDefaultRouteName('main_');
     $controllers->flush();
     $this->assertNotEquals($mainRootController->getRouteName(), $mountedRootController->getRouteName());
 }
开发者ID:robo47,项目名称:Silex,代码行数:10,代码来源:ControllerCollectionTest.php

示例15: testMount

 public function testMount()
 {
     $mounted = new ControllerCollection(new Route());
     $mounted->get('/{name}', function ($name) {
         return new Response($name);
     });
     $app = new Application();
     $app->mount('/hello', $mounted);
     $response = $app->handle(Request::create('/hello/Silex'));
     $this->assertEquals('Silex', $response->getContent());
 }
开发者ID:johnWIll17,项目名称:silex-blog,代码行数:11,代码来源:FunctionalTest.php


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