当前位置: 首页>>代码示例>>PHP>>正文


PHP Import::controller方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:59,代码来源:App.php

示例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);
 }
开发者ID:ahmed555,项目名称:Cupcake,代码行数:24,代码来源:controller.php

示例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());
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:31,代码来源:rewrite.php


注:本文中的Import::controller方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。