本文整理汇总了PHP中ET::notFound方法的典型用法代码示例。如果您正苦于以下问题:PHP ET::notFound方法的具体用法?PHP ET::notFound怎么用?PHP ET::notFound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ET
的用法示例。
在下文中一共展示了ET::notFound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseRequest
/**
* Parse an array of request parts (eg. $_GET["p"] exploded by "/"), work out what controller to set up,
* instantiate it, and work out the method + arguments to dispatch to it.
*
* @param array $parts An array of parts of the request.
* @param array $controllers An array of available controllers, with the keys as the controller names and the
* values as the factory names.
* @return array An array of information about the response:
* 0 => the controller name
* 1 => the controller instance
* 2 => the method to dispatch
* 3 => the arguments to pass when dispatching
* 4 => the response type to use
*
* @package esoTalk
*/
function parseRequest($parts, $controllers)
{
$c = strtolower(@$parts[0]);
$method = "index";
$type = RESPONSE_TYPE_DEFAULT;
// If the specified controller doesn't exist, 404.
if (!isset($controllers[$c])) {
ET::notFound();
}
// Make an instance of the controller.
$controller = ETFactory::make($controllers[$c]);
// Determine the controller method and response type to use. Default to index.
$arguments = array_slice($parts, 2);
if (!empty($parts[1])) {
$method = strtolower($parts[1]);
// If there's a period in the method string, use the first half as the method and the second half as the response type.
if (strpos($method, ".") !== false) {
list($method, $suffix) = explode(".", $method, 2);
if (in_array($suffix, array(RESPONSE_TYPE_VIEW, RESPONSE_TYPE_JSON, RESPONSE_TYPE_AJAX, RESPONSE_TYPE_ATOM))) {
$type = $suffix;
}
}
// Get all of the action methods in the controller class.
$methods = get_class_methods($controller);
foreach ($methods as $k => $v) {
if (strpos($v = strtolower($v), "action_") !== 0) {
unset($methods[$k]);
continue;
}
$methods[$k] = substr($v, 7);
}
// If the method we want to use doesn't exist in the controller...
if (!$method or !in_array($method, $methods)) {
// Search for a plugin with this method. If found, use that.
$found = false;
foreach (ET::$plugins as $plugin) {
if (method_exists($plugin, "action_" . $c . "Controller_" . $method)) {
$found = true;
break;
}
}
// If one wasn't found, default to the "action_index" method.
if (!$found) {
$method = "index";
$arguments = array_slice($parts, 1);
}
}
}
return array($c, $controller, $method, $arguments, $type);
}