本文整理汇总了PHP中SS_HTTPRequest::allParsed方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::allParsed方法的具体用法?PHP SS_HTTPRequest::allParsed怎么用?PHP SS_HTTPRequest::allParsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::allParsed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
// If this is the final portion of the request (i.e. the URL is just /admin), direct to the default panel
if ($request->allParsed()) {
$base = $this->config()->url_base;
$segment = Config::inst()->get($this->config()->default_panel, 'url_segment');
$this->redirect(Controller::join_links($base, $segment));
return $this->getResponse();
} else {
$rules = self::rules();
foreach ($rules as $pattern => $controller) {
if (($arguments = $request->match($pattern, true)) !== false) {
$controllerObj = Injector::inst()->create($controller);
$controllerObj->setSession($this->session);
return $controllerObj->handleRequest($request, $model);
}
}
}
return $this->httpError(404, 'Not found');
}
示例2: routeRequest
function routeRequest(SS_HTTPRequest $request)
{
// Handle the routing
$noun = singleton('RESTRoot');
while (!$request->allParsed()) {
$matched = false;
if ($params = $request->match('$Next!', true)) {
$matched = true;
$next = $params['Next'];
try {
if (method_exists($noun, 'getItem')) {
$noun = $noun->getItem($next);
} else {
$noun = $noun->{$next};
}
} catch (Exception $e) {
if ($e instanceof SS_HTTPResponse_Exception) {
throw $e;
} elseif ($e instanceof RESTException) {
$handler = $this->getHandler($noun);
$handler->respondWithError(array('code' => $e->getCode(), 'exception' => $e));
} else {
$handler = $this->getHandler($noun);
$handler->respondWithError(array('code' => 500, 'exception' => $e));
}
}
if (!$noun) {
$this->httpError(404);
}
}
if (!$matched) {
$this->httpError(404);
}
}
// Find the handler and call
$handler = $this->getHandler($noun);
return $handler->handleRequest($request);
}
示例3: handleURL
/**
* Handle the current URL, parsing a year/month/day/media format, and directing towards any valid controller actions that may be defined.
*
* @URLparameter <{YEAR}> integer
* @URLparameter <{MONTH}> integer
* @URLparameter <{DAY}> integer
* @URLparameter <{MEDIA_URL_SEGMENT}> string
* @return ss http response
*/
public function handleURL()
{
// Retrieve the formatted URL.
$request = $this->getRequest();
$URL = $request->param('URL');
// Determine whether a controller action resolves.
if ($this->hasAction($URL) && $this->checkAccessAction($URL)) {
$output = $this->{$URL}($request);
// The current request URL has been successfully parsed.
while (!$request->allParsed()) {
$request->shift();
}
return $output;
} else {
if (!is_numeric($URL)) {
// Determine whether a media page child once existed, and redirect appropriately.
$response = $this->resolveURL();
if ($response) {
// The current request URL has been successfully parsed.
while (!$request->allParsed()) {
$request->shift();
}
return $response;
} else {
// The URL doesn't resolve.
return $this->httpError(404);
}
}
}
// Determine the formatted URL segments.
$segments = array($URL);
$remaining = $request->remaining();
if ($remaining) {
$remaining = explode('/', $remaining);
// Determine the media page child to display.
$child = null;
$action = null;
// Iterate the formatted URL segments.
$iteration = 1;
foreach ($remaining as $segment) {
if (is_null($action)) {
// Update the current request.
$request->shift();
if ($child) {
// Determine whether a controller action has been defined.
$action = $segment;
break;
} else {
if (!is_numeric($segment)) {
if ($iteration === 4) {
// The remaining URL doesn't match the month/day/media format.
return $this->httpError(404);
}
// Determine the media page child to display, using the URL segment and date.
$children = MediaPage::get()->filter(array('ParentID' => $this->data()->ID, 'URLSegment' => $segment));
if (!empty($segments)) {
// Apply a partial match against the date, since the previous URL segments may only contain the year/month.
$date = array();
foreach ($segments as $previous) {
$date[] = str_pad($previous, 2, '0', STR_PAD_LEFT);
}
$children = $children->filter(array('Date:StartsWith' => implode('-', $date)));
}
$child = $children->first();
// Determine whether a media page child once existed, and redirect appropriately.
if (is_null($child)) {
$response = $this->resolveURL();
if ($response) {
// The current request URL has been successfully parsed.
while (!$request->allParsed()) {
$request->shift();
}
return $response;
} else {
// The URL doesn't match the month/day/media format.
return $this->httpError(404);
}
}
}
}
}
$segments[] = $segment;
$iteration++;
}
// Retrieve the media page child controller, and determine whether an action resolves.
if ($child) {
$controller = ModelAsController::controller_for($child);
// Determine whether a controller action resolves.
if (is_null($action)) {
return $controller;
} else {
//.........这里部分代码省略.........