当前位置: 首页>>代码示例>>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;未经允许,请勿转载。