本文整理汇总了PHP中Silex\ControllerCollection::match方法的典型用法代码示例。如果您正苦于以下问题:PHP ControllerCollection::match方法的具体用法?PHP ControllerCollection::match怎么用?PHP ControllerCollection::match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\ControllerCollection
的用法示例。
在下文中一共展示了ControllerCollection::match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRoutes
protected function addRoutes(ControllerCollection $c)
{
$c->get('/users', 'admin')->bind('users');
$c->match('/users/edit/{id}', 'edit')->assert('id', '\\d*')->bind('useredit');
$c->match('/userfirst', 'first')->bind('userfirst');
$c->post('/user/{action}/{id}', 'modify')->bind('useraction');
$c->match('/profile', 'profile')->bind('profile');
$c->get('/roles', 'viewRoles')->bind('roles');
}
示例2: 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');
}
示例3: connect
public function connect(Application $app)
{
$post = new ControllerCollection(new Route());
$post->match('/', "post.controller:index")->method('GET')->bind('listPosts');
$post->match('/{id}', "post.controller:view")->method('GET|POST')->assert('id', '\\d+');
$post->match('/new', "post.controller:form")->method('POST|GET')->bind('AddPost');
$post->match('/update/{id}', "post.controller:update")->method('POST|GET')->bind('UpdatePost');
$post->match('/destroy/{id}', "post.controller:destroy")->method('GET')->bind('DeletePost');
return $post;
}
示例4: connect
public function connect(Application $app)
{
$user = new ControllerCollection(new Route());
$user->get('/', "user.controller:show");
$user->match('/login', "user.controller:login")->method('POST|GET');
$user->match('/show', "user.controller:show")->method('GET|POST');
$user->match('/add', "user.controller:add")->method('POST|GET');
$user->match('/logout', "user.controller:logout")->method('GET');
return $user;
}
示例5: addRoutes
protected function addRoutes(ControllerCollection $c)
{
$c->get('/about', 'about')->bind('about');
$c->get('/checks', 'checks')->bind('checks');
$c->get('/clearcache', 'clearCache')->bind('clearcache');
$c->get('/', 'dashboard')->bind('dashboard');
$c->get('/omnisearch', 'omnisearch')->bind('omnisearch-results');
$c->match('/prefill', 'prefill')->bind('prefill');
$c->match('/tr/{domain}/{tr_locale}', 'translation')->bind('translation')->assert('domain', 'messages|contenttypes|infos')->value('domain', 'messages')->value('tr_locale', $this->app['locale']);
}
示例6: 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*');
}
示例7: 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');
}
示例8: match
public function match($pattern, $to = null)
{
if ($this->defaultControllerClass && is_string($to) && method_exists($this->defaultControllerClass, $to)) {
$to = [$this->defaultControllerClass, $to];
}
return parent::match($pattern, $to);
}
示例9: 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;
}
示例10: addRoutes
protected function addRoutes(ControllerCollection $controllers)
{
$controllers->post('/api/users', array($this, 'newAction'));
$controllers->get('/api/users/{name}', array($this, 'showAction'))->bind('api_users_show');
$controllers->get('/api/users', array($this, 'listAction'));
$controllers->put('/api/users/{name}', array($this, 'updateAction'));
$controllers->delete('/api/users/{name}', array($this, 'deleteAction'));
$controllers->match('api/users/{name}', array($this, 'updateAction'))->method('PATCH');
}
示例11: 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;
}
示例12: addRoutes
protected function addRoutes(ControllerCollection $c)
{
$c->method('GET|POST');
$c->get('/list/{contenttypeslug}', 'overview')->bind('overview');
$c->match('/add-edit/{contenttypeslug}/{id}', 'edit')->bind('editcontent')->value('id', '');
$c->get('/delete/{contenttypeslug}/{id}', 'delete')->bind('deletecontent');
$c->post('/content-{action}/{contenttypeslug}/{id}', 'modify')->bind('contentaction');
$c->get('/relatedto/{contenttypeslug}/{id}', 'related')->bind('relatedto');
}
示例13: connect
public function connect(Application $app)
{
$controller = new ControllerCollection($app['route_factory']);
$controller->match('/', function () use($app) {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$browsersLocale = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if (in_array($browsersLocale, array('en', 'fr'))) {
$app['locale'] = $browsersLocale;
}
}
return $app->redirect($app['url_generator']->generate('homepage', array('locale' => $app['locale'])));
})->bind('home');
$controller->match('/{locale}/', function () use($app) {
// Get all reports
$reports = $app['repository.report']->findAll();
return $app['twig']->render('Report/list.html.twig', array('reports' => $reports));
})->bind('homepage');
return $controller;
}
示例14: match
public function match($pattern, $to = null)
{
$controller = parent::match($pattern, $to);
$route = $controller->getRoute();
if (!$route instanceof CorsRoute) {
throw new \RuntimeException('The generated route does not have the proper type, did you register the service provider properly?');
}
$route->setControllerCollection($this);
return $controller;
}
示例15: match
/**
* This uses default class/method if not provided
*
* {@inheritdoc}
*/
public function match($pattern, $to = null)
{
if (!$this->defaultControllerClass) {
return parent::match($pattern, $to);
}
if ($to === null && $this->defaultControllerMethod) {
$to = [$this->defaultControllerClass, $this->defaultControllerMethod];
} elseif (is_string($to) && Str::startsWith($to, '::')) {
$to = [$this->defaultControllerClass, substr($to, 2)];
}
return parent::match($pattern, $to);
}