本文整理汇总了PHP中static::method方法的典型用法代码示例。如果您正苦于以下问题:PHP static::method方法的具体用法?PHP static::method怎么用?PHP static::method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: input
public static function input($arguments)
{
if (!defined("STDIN")) {
define("STDIN", fopen('php://stdin', 'r'));
}
$_argv = array();
$_argv['command'] = null;
$_argv['args'] = array();
$_argv['options'] = array();
$i = 0;
foreach ($arguments as $k => $v) {
$v = strtolower($v);
if (substr($v, 0, 2) == '--') {
$_argv['options'][] = $v;
} else {
if ($i == 1) {
$_argv['command'] = $v;
}
if ($i > 1) {
$_argv['args'][] = $v;
}
}
$i++;
}
$command = $_argv['command'];
$method = 'help';
if (strpos($command, ':') !== false) {
list($command, $method) = explode(':', $command);
}
static::$command = $command;
static::$method = $method;
static::$arguments = $_argv['args'];
static::$options = $_argv['options'];
return $_argv;
}
示例2: connect
/**
* Actual routing + sanitizing data
*
* @param $class
* @param array $params
*/
public static function connect($namespace, $class, $params = array())
{
$defaults = array('indexPage' => 'index', 'loginPage' => false, 'loginRedirect' => false);
static::$class = strtolower($class);
$class = $namespace . '\\' . $class;
$params += $defaults;
extract($params);
// Authenticated controllers
if ($loginPage) {
Auth::checkLogin($loginRedirect, $loginPage);
}
$method = $indexPage;
$parameters = array();
if (isset($_SERVER[URI_INFO])) {
$url = explode('/', substr($_SERVER[URI_INFO], 1));
array_shift($url);
if ($url) {
foreach ($url as $key => $element) {
if (!$key && !is_numeric($element)) {
$method = $element;
} else {
$parameters[] = $element;
}
}
}
}
// Check availability
try {
$methodInfo = new \ReflectionMethod($class, $method);
// Methods that start with _ are not accesible from browser
$name = $methodInfo->getName();
if ($name[0] == '_') {
$method = $indexPage;
}
$methodParams = $methodInfo->getParameters();
// Force cast parameters by arguments default value
if ($methodParams) {
foreach ($methodParams as $parameterKey => $parameterValue) {
try {
$defaultValue = $parameterValue->getDefaultValue();
$type = gettype($defaultValue);
if ($defaultValue) {
unset($methodParams[$parameterKey]);
}
// settype($parameters[$parameterKey], $type);
} catch (\Exception $e) {
continue;
}
}
}
// if(count($methodParams) != count($parameters)) {
// $parameters = array();
// }
} catch (\Exception $e) {
$method = $indexPage;
}
static::$method = $method;
call_user_func_array($class . '::' . $method, $parameters);
return;
}
示例3: before
public function before()
{
$this->template = $this->layout . '/template';
$this->controller = Request::active()->controller;
$this->action = Request::active()->action;
static::$method = $this->controller . '/' . $this->action;
$this->render_template();
parent::before();
$this->set_path();
$this->check_maintenance();
$this->init();
}
示例4: before
public function before()
{
$this->controller = Request::active()->controller;
$this->action = Request::active()->action;
static::$method = $this->controller . '/' . $this->action;
$this->data['success'] = false;
Lang::load('app');
$this->render_template();
parent::before();
$this->set_title();
$this->set_path();
$this->init();
}
示例5: initialize
protected static function initialize()
{
if (static::$initialized) {
return;
}
static::$initialized = true;
static::$method = $_SERVER['REQUEST_METHOD'];
static::$request = $_SERVER['REQUEST_URI'];
static::$script = $_SERVER['SCRIPT_NAME'];
static::$original = null;
static::$redirect = null;
static::applyRoutes();
static::route();
}
示例6: dispatch
public static function dispatch()
{
static::$method = Request::method();
$uri = substr(str_replace('/ws/', '/', $_SERVER['REQUEST_URI']), 1);
$tab = explode('/', $uri);
if (count($tab) < 3) {
Api::forbidden();
}
$namespace = current($tab);
$controller = $tab[1];
$action = $tab[2];
$tab = array_slice($tab, 3);
$count = count($tab);
if (0 < $count && $count % 2 == 0) {
for ($i = 0; $i < $count; $i += 2) {
$_REQUEST[$tab[$i]] = $tab[$i + 1];
}
}
$file = APPLICATION_PATH . DS . 'webservices' . DS . $namespace . DS . $controller . '.php';
if (!File::exists($file)) {
Api::NotFound();
}
require_once $file;
$class = 'Thin\\' . ucfirst($controller) . 'Ws';
$i = new $class();
$methods = get_class_methods($i);
$call = strtolower(static::$method) . ucfirst($action);
if (!Arrays::in($call, $methods)) {
Api::NotFound();
}
if (Arrays::in('init', $methods)) {
$i->init($call);
}
$i->{$call}();
if (Arrays::in('after', $methods)) {
$i->after();
}
}
示例7: dispatch
public static function dispatch($module = null)
{
$module = is_null($module) ? 'front' : $module;
$ever = context()->get('MVC404');
if (true !== $ever) {
$file = APPLICATION_PATH . DS . 'config' . DS . SITE_NAME . '_routes.php';
if (File::exists($file)) {
$routes = (include $file);
static::$routes = isAke($routes, $module, []);
}
if (count(static::$routes)) {
$baseUri = Config::get('application.base_uri', '');
if (strlen($baseUri)) {
$uri = strReplaceFirst($baseUri, '', $_SERVER['REQUEST_URI']);
} else {
$uri = $_SERVER['REQUEST_URI'];
}
static::$uri = $uri;
static::$method = Request::method();
return static::find();
}
}
return false;
}
示例8: init
public static function init()
{
//Sanitize inputs
//.Remove magic quotes
if (magic_quotes()) {
$magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
foreach ($magics as &$magic) {
$magic = array_strip_slashes($magic);
}
}
//.Unset globals
foreach (array($_GET, $_POST) as $global) {
if (is_array($global)) {
foreach ($global as $k => $v) {
global ${$k};
${$k} = NULL;
}
}
}
//.Clean post input
array_map(function ($v) {
return Request::clearValue($v);
}, $_POST);
//Remove /public/index.html from path_info..
foreach (array("PATH_INFO", "ORIG_PATH_INFO", "PATH_TRANSLATED", "PHP_SELF") as $k) {
if (isset($_SERVER[$k])) {
$_SERVER[$k] = str_replace("/public/index.html", "/", $_SERVER[$k]);
}
}
static::$server = $_SERVER;
static::$get = $_GET;
static::$post = $_POST;
$_GET = null;
$_POST = null;
$_SERVER = null;
$_REQUEST = null;
//Detect environment
$list = (require J_PATH . "config" . DS . "environments" . EXT);
$env = "";
$envWithWildcard = array_first($list);
$hosts = array(array_get(static::$server, "HTTP_HOST", "localhost"), array_get(static::$server, "SERVER_NAME", "localhost"), array_get(static::$server, "SERVER_ADDR", "localhost"), gethostname());
foreach ($hosts as $host) {
foreach ($list as $k => $v) {
foreach ((array) $v as $hostname) {
if ($hostname != "" && $hostname == $host) {
$env = $k;
break;
} else {
if ($hostname == "*") {
$envWithWildcard = $k;
}
}
}
if (!empty($env)) {
break;
}
}
if (!empty($env)) {
break;
}
}
if (empty($env)) {
$env = $envWithWildcard;
}
static::$env = $env;
//Detect method
$method = strtoupper(array_get(static::$server, "REQUEST_METHOD", "GET"));
if ($method == "POST" && static::hasReq("_method")) {
$methodReq = static::req("_method", "POST");
if (array_search($methodReq, static::$availableMethods) !== false) {
$method = $methodReq;
}
}
static::$method = $method;
}
示例9: setRoute
private static function setRoute($route)
{
$value = explode('.', $route['value']);
$method = explode('/', implode('.', array_slice($value, 1)));
$vars = isset($method[1]) ? explode(',', $method[1]) : array();
static::$controller = str_replace('::', '\\', '\\'.$value[0]);
static::$method = $method[0];
static::$params = $route['params'];
static::$vars = $vars;
static::$extension = (isset($route['params']['extension']) ? $route['params']['extension'] : null);
}
示例10: method
/**
* @return string
*/
public static function method()
{
if (!static::$method) {
if (static::$post->has('_method')) {
static::$method = strtoupper(static::$post->get('_method'));
} else {
static::$method = $_SERVER['REQUEST_METHOD'];
}
}
return static::$method;
}
示例11: __construct
public function __construct()
{
static::$instance = $this;
static::$request = $_REQUEST;
static::$get = $_GET;
static::$post = $_POST;
static::$server = $_SERVER;
static::$headers = static::getAllHeaders();
static::$requestUri = static::prepareRequestUri();
static::$baseUrl = static::prepareBaseUrl();
static::$basePath = static::prepareBasePath();
static::$pathInfo = static::preparePathInfo();
static::$method = static::$server['REQUEST_METHOD'];
}
示例12: controller
public static function controller($dir, $cn)
{
static::$method = Request::method();
$uri = substr(str_replace('/api/', '/', $_SERVER['REQUEST_URI']), 1);
$tab = explode('/', $uri);
dd($tab);
if (count($tab) < 1) {
Api::forbidden();
}
$action = current($tab);
$tab = array_slice($tab, 1);
$count = count($tab);
if (0 < $count && $count % 2 == 0) {
for ($i = 0; $i < $count; $i += 2) {
$_REQUEST[$tab[$i]] = $tab[$i + 1];
}
}
$file = $dir . DS . 'controllers' . DS . 'api.php';
if (!File::exists($file)) {
Api::NotFound();
}
require_once $file;
$class = 'Thin\\' . $cn;
$i = new $class();
$methods = get_class_methods($i);
$call = strtolower(static::$method) . ucfirst($action);
if (!Arrays::in($call, $methods)) {
Api::NotFound();
}
if (Arrays::in('init', $methods)) {
$i->init($call);
}
$i->{$call}();
if (Arrays::in('after', $methods)) {
$i->after();
}
}
示例13: route
public static function route()
{
static::$method = Request::method();
$pjax = isAke(Request::headers(), 'x-pjax', []);
static::$pjax = !empty($pjax);
$uri = substr($_SERVER['REQUEST_URI'], 1);
if (static::$pjax) {
static::$method = 'GET';
}
if (fnmatch("*?*", $uri) && static::$pjax) {
$uri = str_replace('?', '/', $uri);
$uri = str_replace('=', '/', $uri);
$uri = str_replace('&', '/', $uri);
}
if (!strlen($uri)) {
$controller = 'index';
$action = 'home';
} else {
$tab = explode('/', $uri);
if (count($tab) == 1) {
$seg = current($tab);
if (strlen($seg) == 2) {
$_REQUEST['lng'] = strtolower($seg);
$controller = 'index';
$action = 'home';
} else {
$controller = strtolower($seg);
$action = 'index';
}
} elseif (count($tab) == 2) {
$first = current($tab);
$second = end($tab);
if (strlen($first) == 2) {
$_REQUEST['lng'] = strtolower($first);
$controller = $second;
$action = 'index';
} else {
$controller = strtolower($first);
$action = strtolower($second);
}
} else {
$first = current($tab);
$second = $tab[1];
$third = end($tab);
if (strlen($first) == 2) {
$_REQUEST['lng'] = strtolower($first);
$controller = $second;
$action = 'index';
} else {
$controller = strtolower($first);
$action = strtolower($second);
$tab = array_slice($tab, 2);
$count = count($tab);
if (0 < $count && $count % 2 == 0) {
for ($i = 0; $i < $count; $i += 2) {
$_REQUEST[$tab[$i]] = $tab[$i + 1];
}
}
}
}
}
static::$route = ['controller' => $controller, 'action' => $action];
}
示例14: __initialize
/**
* Static Constructor
*
* Checks if the current request is an AJAX request and what HTTP method was used
* when submitting the request.
*
* @return void
*/
public static function __initialize()
{
$req = static::server('http_x_requested_with', false);
static::$ajax = $req and strtolower($req) == 'xmlhttprequest';
static::$method = strtolower(static::server('request_method', 'get'));
}
示例15: init
/**
* Sets up the request.
*/
public static function init()
{
static::$query = new ParameterBag($_GET);
static::$post = new ParameterBag($_POST);
static::$properties = new ParameterBag();
static::$server = new ParameterBag($_SERVER);
static::$headers = static::buildHeaderBag();
static::$method = isset($_POST['_method']) ? $_POST['_method'] : $_SERVER['REQUEST_METHOD'];
static::$requestUri = $_SERVER['REQUEST_URI'];
static::$scriptName = $_SERVER['SCRIPT_NAME'];
static::$basePath = rtrim(str_replace(basename(static::$scriptName), '', static::$scriptName), '/');
static::$pathInfo = str_replace(static::$scriptName, '', static::$requestUri);
static::$pathInfo = static::preparePathInfo();
static::$segments = explode('/', trim(static::$pathInfo, '/'));
}