You are here

public function Route::setMethods in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/routing/Route.php \Symfony\Component\Routing\Route::setMethods()
  2. 8 vendor/symfony/routing/Annotation/Route.php \Symfony\Component\Routing\Annotation\Route::setMethods()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Route.php \Symfony\Component\Routing\Route::setMethods()

Sets the HTTP methods (e.g. 'POST') this route is restricted to. So an empty array means that any method is allowed.

This method implements a fluent interface.

Parameters

string|array $methods The method or an array of methods:

Return value

Route The current Route instance

2 calls to Route::setMethods()
Route::sanitizeRequirement in vendor/symfony/routing/Route.php
Route::__construct in vendor/symfony/routing/Route.php
Constructor.

File

vendor/symfony/routing/Route.php, line 299

Class

Route
A Route describes a route and its parameters.

Namespace

Symfony\Component\Routing

Code

public function setMethods($methods) {
  $this->methods = array_map('strtoupper', (array) $methods);

  // this is to keep BC and will be removed in a future version
  if ($this->methods) {
    $this->requirements['_method'] = implode('|', $this->methods);
  }
  else {
    unset($this->requirements['_method']);
  }
  $this->compiled = null;
  return $this;
}