本文整理汇总了PHP中Route::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::match方法的具体用法?PHP Route::match怎么用?PHP Route::match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMorePath
public function testMorePath()
{
$route = new Route("/users/login");
$url = parse_url("http://example.com/users/login?foo=bar");
$this->assertInternalType("array", $route->match($url["path"], "GET", $url["host"], $url["scheme"]));
$url = parse_url("http://example.com/users/login.php");
$this->assertFalse($route->match($url["path"], "GET", $url["host"], $url["scheme"]));
}
示例2: match
/**
* match(): defined by Route interface.
*
* @see Route::match()
* @param Request $request
* @return RouteMatch|null
*/
public function match(Request $request, $pathOffset = null)
{
$match = $this->route->match($request, $pathOffset);
if ($match !== null) {
if ($this->childRoutes !== null) {
$this->addRoutes($this->childRoutes);
$this->childRoutes = null;
}
$nextOffset = $pathOffset + $match->getInternalParameter('length');
foreach ($this->children as $name => $route) {
$subMatch = $route->match($match, $pathOffset);
if ($subMatch !== null) {
return $match->merge($subMatch);
}
}
$uri = $request->uri();
$path = $uri->getPath();
if ($this->mayTerminate && $nextOffset === strlen($path)) {
return $match;
}
}
return null;
}
示例3: testMatch
/**
* @dataProvider dataProviderForMatch
*/
public function testMatch($method, $pattern, $givenMethod, $givenUri, $expectedReturn, $expectedArguments = array())
{
$route = new Route($method, $pattern, function () {
});
$this->assertEquals($expectedReturn, $route->match($givenMethod, $givenUri));
$this->assertCount(count($expectedArguments), $route->getArguments());
$this->assertEquals($expectedArguments, $route->getArguments());
}
示例4: route
/**
* @param string $module
* @throws \Exception
*/
public static function route($module)
{
if (array_key_exists('REQUEST_URI', $_SERVER) && array_key_exists('QUERY_STRING', $_SERVER)) {
$uri = str_replace('?' . $_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']);
if (!empty($uri) && isset(self::$routes[$module])) {
Route::match(urldecode($uri), self::$routes[$module], $module);
}
}
}
示例5: testRouteMethodPlugins
public function testRouteMethodPlugins()
{
$r = new Route('/test/', '\\Pex\\HttpTest\\View');
$this->assertTrue($r->accept('/test/decor'));
$fn = $r->match('GET', '/test/decor', $parameters);
$this->assertEquals([new \Pex\HttpTest\View(), 'decor'], $fn->getCallable());
$dummyPlugin = function ($name, $args) {
return [$name, $args];
};
$this->assertEquals([['decor', ['foo', 'bar']], ['view', ['abc.php']]], $fn->buildPlugins(['view' => $dummyPlugin, 'decor' => $dummyPlugin]));
}
示例6: testRouteCanMatchSomeRequests
public function testRouteCanMatchSomeRequests()
{
$this->prepareServerParams('test');
$this->assertInstanceOf('Supermon\\Url\\Uri', Route::match(new \Supermon\Http\Request()));
$this->prepareServerParams('test', 'POST');
$this->assertInstanceOf('Supermon\\Url\\Uri', Route::match(new \Supermon\Http\Request()), 'Post request must match');
$this->prepareServerParams('notfound');
$this->assertFalse(Route::match(new \Supermon\Http\Request()), "'notfound' uri dont retrieve nothing");
$this->prepareServerParams('test/var');
$this->assertFalse(Route::match(new \Supermon\Http\Request()), "'test/var' uri must fail retrieve nothing");
$this->prepareServerParams('test/1234');
$this->assertInstanceOf('Supermon\\Url\\Uri', $var_uri = Route::match(new \Supermon\Http\Request()));
$this->assertEquals('testvar', $var_uri->getControllerName());
}
示例7: match
public function match($page)
{
if (parent::match($page)) {
// remap params and return new route as string
$to = explode('/', $this->_to);
foreach ($to as $k => $t) {
foreach ($this->_routeParams->properties() as $key => $value) {
$to[$k] = str_replace(':' . $key, $value, $t);
}
}
$to = implode('/', $to);
return $to;
} else {
return false;
}
}
示例8: assertRoute
public function assertRoute(Route $route, $uri, $expectedReq, $expectedUri)
{
$uri = new UriScript("http://admin.texy.info{$uri}");
$uri->scriptPath = '/';
$uri->appendQuery(array('test' => 'testvalue', 'presenter' => 'querypresenter'));
$httpRequest = new HttpRequest();
$httpRequest->initialize();
$httpRequest->setUri($uri);
$request = $route->match($httpRequest);
if ($request) {
// matched
$params = $request->getParams();
//asort($params); asort($expectedReq['params']);
$this->assertTrue($request->getPresenterName() === $expectedReq['presenter'] && $params === $expectedReq['params']);
unset($params['extra']);
$request->setParams($params);
$result = $route->constructUrl($request, $httpRequest);
$result = strncmp($result, 'http://admin.texy.info', 22) ? $result : substr($result, 22);
$this->assertEquals($expectedUri, $result);
} else {
// not matched
$this->assertEquals($expectedReq, $request);
}
}
示例9: array
Route::post('login', array('uses' => 'HomeController@doLogin'));
Route::get('logout', array('uses' => 'HomeController@doLogout'))->before('auth');
Route::post('register', array('uses' => 'HomeController@doRegister'));
Route::get('register', array('uses' => 'HomeController@showRegister'));
Route::get('forgot-password', array('uses' => 'HomeController@showForgotPassword'))->before('guest');
Route::post('forgot-password', array('uses' => 'HomeController@doForgotPassword'))->before('guest');
Route::get('set-password', array('uses' => 'HomeController@showSetPassword'))->before('guest');
Route::post('set-password', array('uses' => 'HomeController@doSetPassword'))->before('guest');
Route::get('confirm-registration', array('uses' => 'HomeController@showConfirmRegistration'))->before('guest');
Route::post('confirm-registration', array('uses' => 'HomeController@doConfirmAccount'))->before('guest');
//PROFILE
Route::get('profile', array('uses' => 'ProfileController@showProfile'))->before('guest');
Route::resource('profile/payment', 'PaymentOptionController');
Route::post('profile', array('uses' => 'HomeController@doConfirmAccount'))->before('guest');
Route::match(array('GET', 'POST'), '/ok', function () {
return View::make("login");
});
/**
Route::match(array('GET', 'POST'),'/register', function()
{
return View::make('register');
});
Route::match(array('GET', 'POST'),'/resetpassword', function()
{
return View::make('forget');
});
Route::match(array('GET', 'POST'),'/forgot-password', function()
{
return View::make('forget');
});
示例10:
Route::get('mail/move/{id}/{label}', ['middleware' => 'auth', 'uses' => 'Mail\\ConversationsController@moveToLabel'])->name('mail.move');
Route::get('mail/{id}', ['middleware' => 'auth', 'uses' => 'Mail\\MessagesController@showConversation'])->name('mail.conversation')->where('id', '[0-9]+');
Route::get('mail/new/{user_id}', ['middleware' => 'auth', 'uses' => 'Mail\\MessagesController@newMessageForm'])->name('mail.new.form')->where('user_id', '[0-9]+');
Route::post('mail/new', ['middleware' => 'auth', 'uses' => 'Mail\\MessagesController@newMessage'])->name('mail.new');
Route::get('mail/important/{id}/{is_important}', ['middleware' => 'auth', 'uses' => 'Mail\\ConversationsController@important'])->name('mail.important');
// Notifications
Route::get('notifications', ['middleware' => 'auth', 'uses' => 'Notifications\\NotificationsController@index'])->name('notifications');
Route::get('notifications/{id}', ['middleware' => 'auth', 'uses' => 'Notifications\\NotificationsController@callback'])->name('notifications.callback')->where('id', '[0-9]+');
Route::get('notifications/get/{type?}', ['middleware' => 'auth', 'uses' => 'Notifications\\NotificationsController@getNotifications'])->name('notifications.get');
Route::get('notifications/{id}/delete', ['middleware' => 'auth', 'uses' => 'Notifications\\NotificationsController@delete'])->name('notifications.delete')->where('id', '[0-9]+');
// Events
Route::match(['get', 'post'], 'search/{filters?}', ['uses' => 'Events\\EventsController@index'])->name('events');
Route::get('events/new/{id?}', ['middleware' => 'auth', 'uses' => 'Events\\EventsController@newEvent'])->name('events.new')->where('id', '[0-9]+');
Route::get('events/new/inspiration', ['middleware' => 'auth', 'uses' => 'Events\\EventsController@newInspirationEvent'])->name('events.new.inspiration');
Route::post('events/comment', ['middleware' => 'auth', 'uses' => 'Events\\CommentController@save'])->name('events.comment');
Route::match(['get', 'post'], 'events/edit/{id}', ['middleware' => 'auth', 'uses' => 'Events\\EditEventController@index'])->name('events.edit');
Route::get('events/edit/{id}/members', ['middleware' => 'auth', 'uses' => 'Events\\EditEventController@members'])->name('events.edit.members');
Route::get('events/edit/{id}/{user_id}/{status}', ['middleware' => 'auth', 'uses' => 'Events\\EditEventController@status'])->name('events.edit.members.status');
// Event
Route::get('events/{id}/{slug}', 'Events\\EventController@index')->name('events.event');
Route::get('events/{id}/{slug}/members', 'Events\\EventController@members')->name('events.event.members');
Route::get('events/{id}/{slug}/followers', 'Events\\EventController@followers')->name('events.event.followers');
Route::get('events/{id}/{slug}/cancel', ['middleware' => 'auth', 'uses' => 'Events\\EventController@cancel'])->name('events.event.cancel');
Route::get('events/{id}/{slug}/join/{type}', ['middleware' => 'auth', 'uses' => 'Events\\EventController@join'])->name('events.event.join');
Route::get('events/{id}/{slug}/resign', ['middleware' => 'auth', 'uses' => 'Events\\EventController@resign'])->name('events.event.resign');
Route::get('events/{id}/{slug}/share', 'Events\\EventController@share')->name('events.event.share');
// Google Places
Route::get('api/google/places/auto-complete', 'Api\\Google\\PlacesController@autoComplete')->name('api.google.places.autocomplete');
// Cron
Route::get('cron/{schedule}', 'Cron\\CronController@execute');
/**
示例11:
Route::resource('subscriber', 'Backend\\Newsletter\\SubscriberController');
Route::get('subscribers', ['uses' => 'Backend\\Newsletter\\SubscriberController@subscribers']);
Route::resource('statistics', 'Backend\\Newsletter\\StatsController');
});
/* *
* Shop routes for frontend shop
* */
Route::get('/', 'Frontend\\Shop\\ShopController@index');
Route::get('shop', 'Frontend\\Shop\\ShopController@index');
Route::get('shop/product/{id}', 'Frontend\\Shop\\ShopController@show');
/* *
* Checkout routes for frontend shop
* */
Route::get('checkout/resume', 'Frontend\\Shop\\CheckoutController@resume');
Route::get('checkout/confirm', 'Frontend\\Shop\\CheckoutController@confirm');
Route::match(['get', 'post'], 'checkout/send', 'Frontend\\Shop\\CheckoutController@send');
/* *
* Update user adresse via ajax
* */
Route::resource('adresse', 'Frontend\\User\\AdresseController');
Route::post('ajax/adresse/{id}', 'Frontend\\User\\AdresseController@ajaxUpdate');
/* *
* Cart routes for frontend shop
* */
Route::post('cart/addProduct', 'Frontend\\Shop\\CartController@addProduct');
Route::post('cart/removeProduct', 'Frontend\\Shop\\CartController@removeProduct');
Route::post('cart/quantityProduct', 'Frontend\\Shop\\CartController@quantityProduct');
Route::post('cart/applyCoupon', 'Frontend\\Shop\\CartController@applyCoupon');
//Route::get('home', 'HomeController@index');
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
示例12: back
} else {
Request::session()->flash('alert-newsletter-success', 'Su dirección de correo electrónico fue agregada. ¡Muchas gracias!');
}
return back();
});
Route::match(['get', 'post'], '/contacto', function () {
if (Request::isMethod('post')) {
$validator = Validator::make(Request::all(), ['nombre' => 'required|string', 'email' => 'required|email', 'provincia' => 'required|string', 'localidad' => 'required|string']);
if ($validator->fails()) {
return redirect('contacto')->withErrors($validator)->withInput();
}
$envio = Mail::send('email-contacto', ['request' => Request::all()], function ($m) {
// $m->from(Request::get('email'), Request::get('nombre'));
//$m->from('medesconecto@gmail.com', 'Nube');
$m->from('info@nubehilados.com', 'Nube');
$m->replyTo(Request::get('email'), Request::get('nombre'));
$m->to('valeria@nubehilados.com', 'Valeria')->cc('jonathan@nubehilados.com', 'Jonathan')->subject('Contacto web nube');
});
if ($envio) {
Request::session()->flash('alert-success', 'Su mensaje fue enviado. ¡Muchas gracias!');
} else {
Request::session()->flash('alert-danger', 'Ocurrió un error. Por favor intente nuevamente.');
}
}
return view('contacto');
});
Route::get('/como-comprar', function () {
return view('como-comprar');
});
Route::get('/preguntas-frecuentes', function () {
return view('preguntas-frecuentes');
示例13:
*/
Route::get('admin', 'AdminController@index');
Route::get('admin/admin-dashboard', 'AdminController@adminDashboard');
Route::get('admin/leadrouter/dashboard', ['as' => 'leadrouter_dashboard', 'uses' => 'LeadRouterController@dashboard']);
Route::get('admin/search', 'AdminController@search');
Route::get('admin/tasks/edit/{id}', 'TaskController@viewTask');
Route::post('admin/tasks/update/{id}', 'TaskController@updateTask');
Route::patch('admin/leadrouter', 'LeadRouterController@update');
Route::post('admin/leadrouter/getLeadAcceptanceTypes', 'LeadRouterController@getLeadAcceptanceTypes');
Route::get('admin/leadrouter/import', 'LeadRouterController@upload');
Route::resource('admin/leadrouter', 'LeadRouterController');
/**
*Leads
*/
Route::match(['get', 'post'], 'admin/leads/add_lead_to_crm/{id}', 'LeadsController@addLeadToCrm');
Route::match(['get', 'post'], 'admin/leads/reassign_lead/{id}', 'LeadsController@reassignLead');
Route::resource('admin/leads', 'LeadsController');
/**
*Users
*
*
*/
Route::controller('admin/users', 'UsersController');
/**
*
*/
Route::post('admin/task/create_task', 'TaskController@createTask');
/**
*Recruiting
*
*
示例14: function
| and give it the controller to call when that URI is requested.
|
*/
Route::post('member/login', "Auth\\AuthController@postLogin");
Route::post('member/register', 'Auth\\AuthController@postRegister');
# for guest logins
Route::group(['middleware' => 'guest'], function () {
# socialite authentication routes
Route::get('auth/{provider?}', "Auth\\AuthController@redirectToProvider");
Route::get('auth/{provider?}/callback', "Auth\\AuthController@handleProviderCallback");
Route::get('/', "Auth\\AuthController@index");
# regular login
});
Route::group(['middleware' => 'auth', 'prefix' => 'dashboard'], function () {
Route::get('/', "Dashboard@index");
Route::get('logout', "Auth\\AuthController@getLogout");
});
# steps for step2 and step 3
Route::group(['middleware' => 'auth', 'prefix' => 'order'], function () {
Route::match(['get', 'post'], '/step/2', 'UserOrderController@orderProcess');
Route::match(['get', 'post'], '/step/3', 'UserOrderController@computeOrder');
});
Route::group(['middleware' => 'auth'], function () {
Route::post('fetch_menu', function () {
return App\Menu::all();
});
});
# route group for Super Admin
Route::group(['prefix' => 'admin', 'middleware' => 'super'], function () {
Route::get('/dashboard', 'SuperAdmin@index');
});
示例15: function
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Route::group(['middleware' => 'auth'], function () {
Route::group(['prefix' => 'ajax'], function () {
Route::get('translate', ['as' => 'ajax.translate', 'uses' => 'AjaxController@translate']);
Route::get('locations/search', ['as' => 'ajax.locations.searchname', 'uses' => 'AjaxController@searchLocationsOnlyName']);
Route::match(['post', 'put', 'patch'], 'language', ['as' => 'ajax.language', 'uses' => 'AjaxController@updateTranslation']);
Route::delete('participants/{participant}/location/{location}', ['as' => 'ajax.participants.delocate', 'uses' => 'AjaxController@delocate']);
});
Route::group(['prefix' => 'ajax/project/{project}'], function () {
Route::get('/', ['as' => 'ajax.project.base', 'uses' => 'AjaxController@getProject']);
Route::get('/statuscount', ['as' => 'ajax.project.statuscount', 'uses' => 'AjaxController@getStatusCount']);
Route::get('/timegraph', ['as' => 'ajax.project.timegraph', 'uses' => 'AjaxController@timeGraph']);
Route::get('/response', ['as' => 'ajax.project.response', 'uses' => 'AjaxController@getResponse']);
Route::get('/status', ['as' => 'ajax.project.status', 'uses' => 'AjaxController@getAllStatus']);
Route::get('/results', ['as' => 'ajax.project.results', 'uses' => 'AjaxController@getAllResults']);
Route::get('/survey', ['as' => 'ajax.project.survey', 'uses' => 'AjaxController@getSurveyLists']);
Route::post('/questions/sort', ['as' => 'ajax.project.questions.sort', 'uses' => 'AjaxController@sortQuestions']);
Route::post('/question/new', ['as' => 'ajax.project.question.new', 'uses' => 'AjaxController@newQuestion']);
Route::get('/question/{questions}/edit', ['as' => 'ajax.project.question.edit', 'uses' => 'AjaxController@getQuestion']);
Route::match(['patch', 'put'], '/question/{questions}/edit', ['as' => 'ajax.project.question.edit', 'uses' => 'AjaxController@editQuestion']);
Route::match(['patch', 'put'], '/question/{questions}/addlogic', ['as' => 'ajax.project.question.addlogic', 'uses' => 'AjaxController@addLogic']);
Route::get('/pcode/{pcode}', ['as' => 'ajax.project.pcode', 'uses' => 'AjaxController@formValidatePcode']);
Route::get('/person/{person}', ['as' => 'ajax.project.person', 'uses' => 'AjaxController@formValidatePerson']);
Route::get('/questions', ['as' => 'ajax.project.questions', 'uses' => 'AjaxController@getQuestions']);
Route::get('/question/{questions}/answers', ['as' => 'ajax.project.question.answers', 'uses' => 'AjaxController@getAnswers']);
});
});