CakeRequest::onlyAllow PHP Method

onlyAllow() public method

Alias of CakeRequest::allowMethod() for backwards compatibility.
See also: CakeRequest::allowMethod()
Deprecation: 3.0.0 Since 2.5, use CakeRequest::allowMethod() instead.
public onlyAllow ( string | array $methods ) : boolean
$methods string | array Allowed HTTP request methods.
return boolean true
    public function onlyAllow($methods)
    {
        if (!is_array($methods)) {
            $methods = func_get_args();
        }
        return $this->allowMethod($methods);
    }

Usage Example

 /**
  * Test allowMethod method
  *
  * @return void
  */
 public function testAllowMethod()
 {
     $_SERVER['REQUEST_METHOD'] = 'PUT';
     $request = new CakeRequest('/posts/edit/1');
     $this->assertTrue($request->allowMethod(array('put')));
     // BC check
     $this->assertTrue($request->onlyAllow(array('put')));
     $_SERVER['REQUEST_METHOD'] = 'DELETE';
     $this->assertTrue($request->allowMethod('post', 'delete'));
     // BC check
     $this->assertTrue($request->onlyAllow('post', 'delete'));
 }
All Usage Examples Of CakeRequest::onlyAllow