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


PHP Router::delete方法代码示例

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

示例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());
 }
开发者ID:sugiphp,项目名称:routing,代码行数:22,代码来源:RouterTest.php

示例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())));

});
开发者ID:neogeek,项目名称:Overseer-Framework,代码行数:30,代码来源:api.php

示例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']);
}
开发者ID:NeutralAsh,项目名称:boilerplate,代码行数:28,代码来源:index.php

示例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]);
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:12,代码来源:module.php

示例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);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:12,代码来源:router.php

示例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]);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:30,代码来源:module.php

示例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) {
开发者ID:Leoche,项目名称:GameSync,代码行数:32,代码来源:index.php

示例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']);
开发者ID:wAmpIre,项目名称:netmon,代码行数:31,代码来源:routereditor.php


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