1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAV\Exception; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\DAV; 6*a1a3b679SAndreas Boehler 7*a1a3b679SAndreas Boehler/** 8*a1a3b679SAndreas Boehler * MethodNotAllowed 9*a1a3b679SAndreas Boehler * 10*a1a3b679SAndreas Boehler * The 405 is thrown when a client tried to create a directory on an already existing directory 11*a1a3b679SAndreas Boehler * 12*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 13*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/) 14*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License 15*a1a3b679SAndreas Boehler */ 16*a1a3b679SAndreas Boehlerclass MethodNotAllowed extends DAV\Exception { 17*a1a3b679SAndreas Boehler 18*a1a3b679SAndreas Boehler /** 19*a1a3b679SAndreas Boehler * Returns the HTTP statuscode for this exception 20*a1a3b679SAndreas Boehler * 21*a1a3b679SAndreas Boehler * @return int 22*a1a3b679SAndreas Boehler */ 23*a1a3b679SAndreas Boehler function getHTTPCode() { 24*a1a3b679SAndreas Boehler 25*a1a3b679SAndreas Boehler return 405; 26*a1a3b679SAndreas Boehler 27*a1a3b679SAndreas Boehler } 28*a1a3b679SAndreas Boehler 29*a1a3b679SAndreas Boehler /** 30*a1a3b679SAndreas Boehler * This method allows the exception to return any extra HTTP response headers. 31*a1a3b679SAndreas Boehler * 32*a1a3b679SAndreas Boehler * The headers must be returned as an array. 33*a1a3b679SAndreas Boehler * 34*a1a3b679SAndreas Boehler * @param \Sabre\DAV\Server $server 35*a1a3b679SAndreas Boehler * @return array 36*a1a3b679SAndreas Boehler */ 37*a1a3b679SAndreas Boehler function getHTTPHeaders(\Sabre\DAV\Server $server) { 38*a1a3b679SAndreas Boehler 39*a1a3b679SAndreas Boehler $methods = $server->getAllowedMethods($server->getRequestUri()); 40*a1a3b679SAndreas Boehler 41*a1a3b679SAndreas Boehler return [ 42*a1a3b679SAndreas Boehler 'Allow' => strtoupper(implode(', ', $methods)), 43*a1a3b679SAndreas Boehler ]; 44*a1a3b679SAndreas Boehler 45*a1a3b679SAndreas Boehler } 46*a1a3b679SAndreas Boehler 47*a1a3b679SAndreas Boehler} 48