本文整理汇总了PHP中Router::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::delete方法的具体用法?PHP Router::delete怎么用?PHP Router::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
public function testDelete()
{
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$_SERVER['REQUEST_URI'] = '/test';
$t = false;
Router::delete('/test', function () use(&$t) {
$t = true;
return false;
})->process();
$this->assertTrue($t);
}
示例2: testMethods
public function testMethods()
{
$router = new Router();
$this->assertFalse($router->has("home"));
$this->assertNull($router->get("home"));
$this->assertSame(0, $router->count());
// add one
$this->assertInstanceOf("SugiPHP\\Routing\\Router", $router->add("home", new Route("/")));
$this->assertSame(1, $router->count());
$this->assertTrue($router->has("home"));
$this->assertInstanceOf("SugiPHP\\Routing\\Route", $router->get("home"));
// change it
$this->assertInstanceOf("SugiPHP\\Routing\\Router", $router->set("home", new Route("/foo")));
$this->assertSame(1, $router->count());
$this->assertTrue($router->has("home"));
$this->assertInstanceOf("SugiPHP\\Routing\\Route", $router->get("home"));
// remove it
$this->assertInstanceOf("SugiPHP\\Routing\\Router", $router->delete("home"));
$this->assertFalse($router->has("home"));
$this->assertNull($router->get("home"));
$this->assertSame(0, $router->count());
}
示例3: function
Router::setContentType('application/json');
Router::setStatus(200, 'OK');
die(json_encode(array('status'=>'OK', 'data'=>array('user_id'=>$params[1], 'username'=>'neogeek'))));
});
// curl -X PUT -d "email=neo@neo-geek.net" http://example.com/examples/router/user/1
$app->put('/user/:int', function ($params) {
Router::setContentType('application/json');
Router::setStatus(200, 'OK');
parse_str(file_get_contents('php://input'), $_PUT);
die(json_encode(array('status'=>'OK', 'data'=>array('user_id'=>$params[1], 'username'=>'neogeek', 'email'=>$_PUT['email']))));
});
// curl -X DELETE http://example.com/examples/router/user/1
$app->delete('/user/:int', function ($params) {
Router::setContentType('application/json');
Router::setStatus(200, 'OK');
die(json_encode(array('status'=>'OK', 'data'=>array())));
});
示例4: Router
<?php
//Include Config files.
include 'app/config/routes.php';
include 'app/config/paths.php';
//Initialize Autoloader.
include 'app/system/autoloader.php';
autoloader::register();
//Initialize the router with URL and route config file.
$router = new Router($routes, $_GET['url']);
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$router->get($_GET['url']);
break;
case 'POST':
$router->post($_GET['url']);
break;
case 'PUT':
//need to be done
$router->put($_GET['url']);
break;
case 'DELETE':
//need to be done
$router->delete($_GET['url']);
break;
default:
die('not a valid Request Method, request method =' . $_SERVER['REQUEST_METHOD']);
}
示例5: unload
/**
* Unloads a module from the stack.
*
* @param string $module The module name
* @return void
*/
public static function unload($module)
{
// delete all routes for this module
\Router::delete($module . '/(:any)');
unset(static::$modules[$module]);
}
示例6: test_add_route_and_router_option_name
public function test_add_route_and_router_option_name()
{
$path = 'testing/route';
$name = 'option_name';
$options = array('name' => $name);
$prepend = false;
$case_sensitive = null;
Router::add($path, $options, $prepend, $case_sensitive);
$this->assertEquals($path, Router::$routes[$name]->path);
$this->assertEquals($name, Router::$routes[$name]->name);
Router::delete($name);
}
示例7: unload
/**
* Unloads a module from the stack.
*
* @param string $module The module name
* @return void
*/
public static function unload($module)
{
// we can only unload a loaded module
if (isset(static::$modules[$module])) {
$path = static::$modules[$module];
if (is_file($path .= 'config/routes.php')) {
// load and add the module routes
$module_routes = \Fuel::load($path);
$route_names = array();
foreach ($module_routes as $name => $_route) {
if ($name === '_root_') {
$name = $module;
} elseif (strpos($name, $module . '/') !== 0 and $name != $module and $name !== '_404_') {
$name = $module . '/' . $name;
}
$route_names[] = $name;
}
// delete the defined module routes
\Router::delete($route_names);
}
}
// delete this module
unset(static::$modules[$module]);
}
示例8: function
}
$entry = $folder . "/" . $subfolder . "/" . $entry;
$newwhitelist = $config->get("whitelist");
if (!in_array($entry, $newwhitelist)) {
$newwhitelist[] = $entry;
$config->set("whitelist", $newwhitelist);
}
echo json_encode(array("code" => "200"));
});
$router->delete('/api/whitelist/:entry', function ($entry) use($auth, $config, $session) {
if (!$auth->isConnected()) {
header("Location: " . ROOT . "login");
die;
}
$newwhitelist = $config->get("whitelist");
foreach ($newwhitelist as $i => $item) {
if ($item == $entry) {
array_splice($newwhitelist, $i, 1);
}
}
$config->set("whitelist", $newwhitelist);
echo json_encode(array("code" => "200"));
});
$router->delete('/api/whitelist/:folder/:entry', function ($folder, $entry) use($auth, $config, $session) {
if (!$auth->isConnected()) {
header("Location: " . ROOT . "login");
die;
}
$entry = $folder . "/" . $entry;
$newwhitelist = $config->get("whitelist");
foreach ($newwhitelist as $i => $item) {
if ($item == $entry) {
示例9: header
if ($_GET['section'] == "insert_reset_auto_assign_hash") {
$router_data = Router_old::getRouterInfo($_GET['router_id']);
if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, (int) $router_data['user_id'])) {
$insert_result = RouterEditor::resetRouterAutoAssignHash($_GET['router_id']);
header('Location: ./routereditor.php?section=edit&router_id=' . $_GET['router_id']);
} else {
Permission::denyAccess(PERM_ROOT, (int) $router_data['user_id']);
}
}
if ($_GET['section'] == "insert_delete") {
$router = new Router((int) $_GET['router_id']);
$router->fetch();
//Root and owning user can delete router
if (permission::checkIfUserIsOwnerOrPermitted(PERM_ROOT, $router->getUserId())) {
if ($_POST['really_delete'] == 1) {
if ($router->delete()) {
$message[] = array("Der Router " . $router->getHostname() . " wurde entfernt.", 1);
Message::setMessage($message);
header('Location: ./user.php?user_id=' . $_SESSION['user_id']);
} else {
$message[] = array("Der Router konnte nicht entfernt werden.", 2);
Message::setMessage($message);
header('Location: ./routereditor.php?section=edit&router_id=' . $_GET['router_id']);
}
} else {
$message[] = array("Zum löschen des Routers ist eine Bestätigung erforderlich!", 2);
Message::setMessage($message);
header('Location: ./routereditor.php?section=edit&router_id=' . $_GET['router_id']);
}
} else {
Permission::denyAccess(PERM_ROOT, (int) $router_data['user_id']);