本文整理汇总了PHP中Request::route方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::route方法的具体用法?PHP Request::route怎么用?PHP Request::route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::route方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(Request $request)
{
$this->middleware('guest');
$lang = $request->route()->parameter('lang');
View::composer('auth.register', function ($view) use($lang) {
$view->with('countries', Country::withTranslation()->get());
});
$this->loginPath = route('sign in', $request->route()->parameters());
}
示例2: __construct
/**
* @param int $total Total items
* @param int $limit Items limit per page, if not set the config value will be used
* @param int $current If not set, it will be auto detected
*
* @uses Request::current
* @uses Kohana::$config
*/
public function __construct($total, $limit = null, $current = null)
{
$this->request(Request::current());
$this->route($this->_request->route());
$this->_route_params = array('directory' => $this->_request->directory(), 'controller' => $this->_request->controller(), 'action' => $this->_request->action()) + $this->_request->param();
$this->_config = Kohana::$config->load('pagination');
if ($current === null) {
$this->_current = (int) $this->_detect_current_page();
} else {
$this->_current = (int) $current;
}
$this->_total = (int) $total;
$this->_limit = (int) $limit ? $limit : $this->_config->limit;
}
示例3: buildNavMenu
public function buildNavMenu()
{
$buildNavMenu = '<div class="col-sm-3 col-md-2 sidebar">';
$activePage = \Request::route()->getPath();
//basename($_SERVER['PHP_SELF']);
$header_count = 0;
$menuItems = file('menu_items.txt');
foreach ($menuItems as $menuItem) {
$nav = explode(":", $menuItem);
$page = trim($nav[0]);
$link = trim($nav[1]);
//if($link == 'Header'){
if (starts_with($link, 'Header')) {
if ($header_count >= 1) {
$buildNavMenu = $buildNavMenu . '</ul>';
}
$buildNavMenu = $buildNavMenu . '<ul class="nav nav-sidebar">';
$buildNavMenu = $buildNavMenu . '<li><a href="' . substr($link, 7) . '">' . $page . '</a></li>';
$header_count++;
} elseif ($link == $activePage) {
$buildNavMenu = $buildNavMenu . '<li class="active"><a>' . $page . '</a></li>';
} else {
$buildNavMenu = $buildNavMenu . '<li><a href="' . $link . '">' . $page . '</a></li>';
}
}
$buildNavMenu = $buildNavMenu . '</ul></div>';
return $buildNavMenu;
}
示例4: detectInformation
protected function detectInformation()
{
$arrInfo = ['main' => ['table' => 'prj02_table0001', 'platform' => 1], 'rakunoie' => ['table' => 'prj02_table0001', 'platform' => 1], 'desio' => ['table' => 'prj02_table0001', 'platform' => 1], 'zeroclub' => ['table' => 'prj02_table0001', 'platform' => 1], 'bj_basic' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctorsair' => ['table' => 'prj02_table0001', 'platform' => 1], 'lifestylenavi' => ['table' => 'prj02_table0001', 'platform' => 1], 'kaiteki' => ['table' => 'prj02_table0001', 'platform' => 1], 'nisetai2' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctors_kids' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctors_plan' => ['table' => 'prj02_table0001', 'platform' => 1], 'crescasa' => ['table' => 'prj02_table0006', 'platform' => 1], 'vtoheim' => ['table' => 'prj02_table0036', 'platform' => 1], 'spsex' => ['table' => 'prj02_table0037', 'platform' => 1], 'kageyama' => ['table' => 'prj02_table0039', 'platform' => 1], 'snowpeak' => ['table' => 'prj02_table0040', 'platform' => 1], 'attaka' => ['table' => 'prj02_table0041', 'platform' => 1], 'neostory' => ['table' => 'prj02_table0042', 'platform' => 1], 'senior' => ['table' => 'prj02_table0034', 'platform' => 1], 'main_sm' => ['table' => 'prj02_table0001', 'platform' => 2], 'spsex_sm' => ['table' => 'prj02_table0038', 'platform' => 2], '20heim_sm' => ['table' => 'prj02_table0043', 'platform' => 2], 'cart' => ['table' => 'prj02_table0001', 'platform' => 3], '43up' => ['table' => 'prj02_table0001', 'platform' => 1]];
$arrParameters = \Request::route()->parameters();
if (!isset($arrParameters['catalogItem']) || !in_array($arrParameters['catalogItem'], array_keys($arrInfo))) {
abort(404);
}
// fillable attributes
switch ($arrParameters['catalogItem']) {
case 'senior':
$arrFillable = ['ext6', 'ext7', 'ext8', 'ext9'];
break;
case '43up':
$arrFillable = ['ext6', 'ext8', 'ext18', 'ext19', 'ext20', 'ext21', 'ext23', 'ext24', 'ext25', 'ext29', 'ext30', 'ext31', 'ext32', 'ext33', 'ext34', 'ext35', 'ext36', 'ext37', 'ext38', 'ext39', 'ext40'];
break;
default:
$arrFillable = ['ext6', 'ext7', 'ext8', 'ext9', 'ext41', 'ext42', 'ext10', 'ext11', 'ext12', 'ext13', 'ext14', 'ext15', 'ext16', 'ext17', 'ext18', 'ext19', 'ext20', 'ext21', 'ext22', 'ext23', 'ext24', 'ext25', 'ext27', 'ext28', 'ext78', 'ext79', 'ext80', 'ext81', 'ext82', 'ext84', 'ext85', 'ext86', 'ext83', 'important', 'email_confirmation'];
break;
}
$this->fillable = array_merge($this->fillable, $arrFillable);
/* other attributes */
// Set table
$this->table = $arrInfo[$arrParameters['catalogItem']]['table'];
// attributes for load csv
$this->platform = $arrInfo[$arrParameters['catalogItem']]['platform'];
$this->platformName = $this->platform == 2 ? 'catalog_mobile' : 'catalog';
}
示例5: assignDynamicFieldsToPageObject
/**
* Pass dynamicFields to view
*
* @param $view
* @return mixed
*/
private function assignDynamicFieldsToPageObject($view)
{
$entityDynamic = null;
$data = $view->getData();
//TODO Fix with event
if (count($data)) {
$arrType = config('asgard.dynamicfield.config.entity-type');
$arrType = array_keys($arrType);
// edit entity
foreach ($data as $item) {
if (is_object($item)) {
$className = get_class($item);
if (in_array($className, $arrType)) {
$entityDynamic = $item;
break;
}
}
}
}
// initial model data for create new;
if (is_null($entityDynamic)) {
$router = \Request::route()->getName();
$arrCreateRouter = config('asgard.dynamicfield.config.router');
if (array_key_exists($router, $arrCreateRouter)) {
$entityDynamic = new $arrCreateRouter[$router]();
}
}
$view->with('entityDynamic', $entityDynamic);
return $view;
}
示例6: readDbObjectForInjection
/**
* @param $parameters
*/
protected function readDbObjectForInjection($parameters)
{
/** @var Route $route */
$route = \Request::route();
$object = null;
foreach ($parameters as $key => $value) {
if ($value instanceof CmfDbObject) {
// get only last object in params
$object = $value;
}
}
if (!empty($object)) {
$id = $route->parameter('id', false);
if ($id === false && \Request::method() !== 'GET') {
$id = \Request::get('id', false);
}
if (empty($id)) {
$this->sendRecordNotFoundResponse();
}
$conditions = ['id' => $id];
$this->addConditionsForDbObjectInjection($route, $object, $conditions);
$this->addParentIdsConditionsForDbObjectInjection($route, $object, $conditions);
$object->find($conditions);
if (!$object->exists()) {
$this->sendRecordNotFoundResponse();
}
}
}
示例7: loadCrudSubtitle
protected function loadCrudSubtitle()
{
list($controller, $action) = explode('@', \Request::route()->getAction()['uses']);
if ($this->subtitle === null) {
if (array_search($action, ['create', 'edit', 'index']) !== FALSE) {
$this->subtitle = trans('crud.' . $action);
}
}
}
示例8: current_route
function current_route($property = null)
{
$route = Request::route();
switch ($property) {
case 'name':
return $route->getName();
}
return $route;
}
示例9: active_menu
/**
* Get user country from session.
* @param string $routeName name of route to check
* @param bool $firstOccurrence active to find first occurrence of route, this method is valid to active menu on subsections
* @return boolean
*/
function active_menu($routeName, $firstOccurrence = false)
{
if ($firstOccurrence) {
return strpos(Request::url(), route($routeName)) === 0;
} else {
if (Request::route() !== null) {
return Request::route()->getName() == $routeName;
}
}
}
示例10: set
public function set($key = '', $current_url = '')
{
if (empty($key)) {
$key = \Request::route()->getName();
}
if (empty($current_url)) {
$current_url = \Request::fullUrl();
}
$session_key = $this->session_key($key);
\Session::put($session_key, $current_url);
}
示例11: getResponse
/**
* Get object of Response.
*
* @param string $packageRoot
* @param Request $request
*
* @return Response|null
*/
public function getResponse($packageRoot, Request $request)
{
$packageRoot = rtrim($packageRoot, '/');
$path = $packageRoot . '/Route/' . $request->route() . '/' . $request->method() . '.php';
if (file_exists($path)) {
require $path;
$controllerClass = $request->package() . '\\Route_' . str_replace('/', '_', $request->route()) . '\\' . $request->method();
/**
* @var BaseController $controller
*/
$controller = new $controllerClass($packageRoot, $request);
/**
* Call handler.
*/
$handler = $_POST['handler'] ?? $_GET['handler'] ?? 'index';
if (preg_match('/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/', $handler) && method_exists($controllerClass, $handler)) {
$controller->{$handler}();
return $controller->getResponse();
}
}
return null;
}
示例12: process
public static function process(Request $request, HttpResponse $response)
{
$route = $request->route($_SERVER['REQUEST_URI']);
$route = array_merge(self::$_defaultRoute, $route);
if (!file_exists($path = FrontController::$dirname . '/controllers/' . ucfirst($route['module']) . 'Controller.php')) {
echo $path;
throw new ControleurIntrouvableException('Controller not found!');
}
require_once $path;
$class = ucfirst($route['module']) . 'Controller';
$controller = new $class($request, $response);
$controller->_moduleName = $route['module'];
return $controller->launch($route['action']);
}
示例13: detectInformation
protected function detectInformation()
{
$arrInfo = ['inquire' => ['main' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'estate' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'others' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'member' => ['table' => 'prj02_table0003', 'fillable' => array_merge($this->fillable, ['ext53', 'ext54', 'ext55', 'ext56', 'ext59', 'ext60', 'ext61', 'ext62', 'ext6', 'ext63'])], 'contact' => ['table' => 'prj02_table0004', 'fillable' => array_merge($this->fillable, ['ext7', 'ext8', 'ext18', 'ext19', 'ext25', 'ext29', 'ext30', 'ext32', 'ext33', 'ext35', 'ext50', 'ext51', 'ext53', 'ext60', 'ext74', 'ext75', 'ext76', 'ext77'])], 'air_comf' => ['table' => 'prj02_table0027', 'fillable' => array_merge($this->fillable, ['ext8', 'ext9', 'ext10', 'ext11', 'ext12', 'ext13', 'ext14', 'ext15', 'ext16', 'ext17', 'ext18', 'ext19', 'ext20', 'ext21', 'ext22', 'ext23', 'ext24', 'ext25', 'ext27', 'ext28', 'ext41', 'ext42', 'ext43', 'ext78', 'ext79', 'ext80', 'ext81', 'ext82', 'ext83', 'ext84', 'ext85', 'ext86', 'important'])], 'senior' => ['table' => 'prj02_table0033', 'fillable' => array_merge($this->fillable, ['ext53', 'ext6', 'ext7', 'ext8'])], 'main_sm' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext52', 'ext53'])]], 'mailmag' => ['main_sm' => ['table' => 'prj02_table0011', 'fillable' => ['uid', 'form', 'email1']]]];
$arrParameters = \Request::route()->parameters();
/* if (! isset($arrParameters['item']) ||
! isset($arrParameters['slug']) ||
! isset($arrInfo[ $arrParameters['slug'] ][ $arrParameters['item'] ])
) {
abort(404);
} */
$arrInfo = $arrInfo[$arrParameters['slug']][$arrParameters['item']];
$this->table = $arrInfo['table'];
$this->fillable = $arrInfo['fillable'];
}
示例14: get_css_class_for_page
function get_css_class_for_page($type)
{
$array = ['nid', 'token'];
$paths = Request::route();
$path = $paths->uri();
$cssClass = implode(' ', explode('/', $path));
foreach ($array as $value) {
if (preg_match('/(\\W|^)({' . $value . '})(\\W|$)/', $path)) {
$path = str_replace($value, $paths->parameters()[$value], $path);
}
}
$path = clean_character($path);
$cssClass = clean_character($cssClass, 'page');
return $cssClass . ' ' . $type . '-' . $path;
}
示例15: getPage
public function getPage()
{
// $route = $request->route();
// $name = $route->getName();
$page = \Request::route()->getName();
$topics = Topic::all();
$resources = Resource::all();
$data = ["topics" => $topics, "resources" => $resources];
// return $data["topics"];
if ($page) {
return view("admin.{$page}", $data);
} else {
return redirect('/admin', $data);
}
}