コード例 #1
0
ファイル: utils.php プロジェクト: ddliu/tinyark
function ark_event()
{
    call_user_func_array(array(Ark::app()->event, 'attach'), func_get_args());
}
コード例 #2
0
ファイル: index.php プロジェクト: ddliu/tinyark
<?php

require dirname(__FILE__) . '/../../src/ark.php';
$env = $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ? 'dev' : 'prod';
$debug = $_SERVER['REMOTE_ADDR'] === '127.0.0.1';
Ark::createWebApp(dirname(__FILE__) . '/app', $env, $debug)->run();
コード例 #3
0
ファイル: app.php プロジェクト: ddliu/tinyark
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $q = _ark_parse_query_path($this->config->get('route.route_var', 'r'));
     $q['https'] = $this->request->isSecure();
     $q['method'] = $this->request->getMethod();
     //Request method validation
     if (!in_array($q['method'], array('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS'))) {
         $response = Ark::getHttpErrorResponse(405);
         $this->respond($resonse);
     } else {
         $this->dispatchResponseEvent('app.dispatch', $this, $q);
     }
 }
コード例 #4
0
ファイル: controller.php プロジェクト: ddliu/tinyark
 public function __construct()
 {
     $this->request = Ark::app()->getRequest();
     $this->init();
 }
コード例 #5
0
ファイル: ark.php プロジェクト: ddliu/tinyark
        foreach (self::$dirs as $dir => $hasChild) {
            if ($hasChild) {
                $file = $dir . '/' . $name_path . '.php';
            } else {
                $file = $dir . '/' . $name . '.php';
            }
            if (file_exists($file)) {
                require $file;
                return true;
            }
        }
        return false;
    }
    public static function registerPrefix($prefix, $path)
    {
        self::$prefixes[$prefix] = $path;
    }
    public static function loadPrefix($name)
    {
        foreach (self::$prefixes as $prefix => $path) {
            $prefix_length = strlen($prefix);
            if (substr($name, 0, $prefix_length + 1) === $prefix . '_') {
                $file = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
                require $file;
                return true;
            }
        }
    }
}
Ark::autoloadFramework();