本文整理汇总了PHP中Import::controller方法的典型用法代码示例。如果您正苦于以下问题:PHP Import::controller方法的具体用法?PHP Import::controller怎么用?PHP Import::controller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Import
的用法示例。
在下文中一共展示了Import::controller方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Contrutor da classe
* @param string $url url acessada pelo usuário
*/
public function __construct($url)
{
define('CACHE_TIME', 60);
$cache_config = Config::get('cache');
if ($cache_config['page']) {
$cache = Cache::factory();
if ($cache->has(URL)) {
$data = $cache->read(URL);
exit($data);
}
}
$registry = Registry::getInstance();
$this->args = $this->args($url);
//I18n
define('lang', $this->args['lang']);
define('LANG', $this->args['lang']);
$i18n = I18n::getInstance();
$i18n->setLang(LANG);
$registry->set('I18n', $i18n);
function __($string, $format = null)
{
return I18n::getInstance()->get($string, $format);
}
function _e($string, $format = null)
{
echo I18n::getInstance()->get($string, $format);
}
define('controller', Inflector::camelize($this->args['controller']) . 'Controller');
define('action', str_replace('-', '_', $this->args['action']));
define('CONTROLLER', Inflector::camelize($this->args['controller']) . 'Controller');
define('ACTION', str_replace('-', '_', $this->args['action']));
try {
header('Content-type: text/html; charset=' . Config::get('charset'));
Import::core('Controller', 'Template', 'Annotation');
Import::controller(CONTROLLER);
$this->controller();
$this->auth();
$tpl = new Template();
$registry->set('Template', $tpl);
$tpl->render($this->args);
if ($cache_config['page']) {
$cache = Cache::factory();
$data = ob_get_clean();
$cache->write(URL, $data, $cache_config['time']);
}
Debug::show();
} catch (PageNotFoundException $e) {
header('HTTP/1.1 404 Not Found');
$this->loadError($e);
exit;
} catch (Exception $e) {
header('HTTP/1.1 500 Internal Server Error');
$this->loadError($e);
}
}
示例2: handle_request
public function handle_request($params)
{
if (array_key_exists("format", $params) === false) {
$params["format"] = "html";
}
$this->params = $params;
$controller_name = Inflector::camelize($params["controller"], "first");
Logger::process_controller($controller_name, $params["action"], env("REQUEST_METHOD"), $params);
if (Import::controller($params["controller"])) {
Import::helper($params["controller"]);
$helper_name = "{$controller_name}Helper";
$this->controller = new $controller_name($this->request_uri, $params);
if (class_exists($helper_name)) {
$this->controller->helper = new $helper_name();
}
$action = $params["action"];
} else {
$this->controller = new self($this->request_uri, $params);
$action = "not_found";
$this->controller->{$action}();
}
$this->controller->format = $this->params["format"];
$this->controller->handle_action($action);
}
示例3: rewrite
* @param <type> $preg
* @param <type> $module
* @param <type> $func
* @return <type>
*/
function rewrite($preg, $module, $func)
{
if (!$this->rewrite) {
preg_match_all($preg, $_SERVER['REQUEST_URI'], $rt);
if (isset($rt['0']['0']) && $rt['0']['0'] != '') {
if (isset($rt['1'])) {
$args = $rt['1'];
}
$this->module = $module;
$this->function = $func;
if (!empty($args)) {
$this->parms = array_merge($args, $this->parms);
}
$this->rewrite = true;
}
}
return $this->rewrite;
}
}
/**
* Running
*/
$app = Import::controller();
$app->App = Import::model();
$re = Import::route();
call_user_func_array(array($app, 'action'), $re->load());