當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ET::notFound方法代碼示例

本文整理匯總了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);
}
開發者ID:xiaolvmu,項目名稱:Techllage,代碼行數:66,代碼來源:functions.general.php


注:本文中的ET::notFound方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。