Orno\Route\RouteCollection::delete PHP Метод

delete() публичный Метод

Add a route that responds to DELETE HTTP method
public delete ( string $route, string | Closure $handler, integer $strategy = self::REQUEST_RESPONSE_STRATEGY ) : RouteCollection
$route string
$handler string | Closure
$strategy integer
Результат RouteCollection
    public function delete($route, $handler, $strategy = self::REQUEST_RESPONSE_STRATEGY)
    {
        return $this->addRoute('DELETE', $route, $handler, $strategy);
    }

Usage Example

Пример #1
0
 /**
  * Asserts that global strategy is used when set
  *
  * @return void
  */
 public function testGlobalStrategyIsUsedWhenSet()
 {
     $router = new RouteCollection();
     $router->setStrategy(RouteCollection::URI_STRATEGY);
     $router->get('/route/{wildcard}', 'handler_get', RouteCollection::RESTFUL_STRATEGY);
     $router->post('/route/{wildcard}', 'handler_post', RouteCollection::URI_STRATEGY);
     $router->put('/route/{wildcard}', 'handler_put', RouteCollection::REQUEST_RESPONSE_STRATEGY);
     $router->patch('/route/{wildcard}', 'handler_patch');
     $router->delete('/route/{wildcard}', 'handler_delete');
     $router->head('/route/{wildcard}', 'handler_head');
     $router->options('/route/{wildcard}', 'handler_options');
     $routes = (new \ReflectionClass($router))->getProperty('routes');
     $routes->setAccessible(true);
     $routes = $routes->getValue($router);
     $this->assertCount(7, $routes);
     $this->assertSame($routes['handler_get'], ['strategy' => 2]);
     $this->assertSame($routes['handler_post'], ['strategy' => 2]);
     $this->assertSame($routes['handler_put'], ['strategy' => 2]);
     $this->assertSame($routes['handler_patch'], ['strategy' => 2]);
     $this->assertSame($routes['handler_delete'], ['strategy' => 2]);
     $this->assertSame($routes['handler_head'], ['strategy' => 2]);
     $this->assertSame($routes['handler_options'], ['strategy' => 2]);
 }
All Usage Examples Of Orno\Route\RouteCollection::delete