1<?php 2 3namespace Sabre\DAV\Browser; 4 5use Sabre\DAV; 6use Sabre\HTTP\RequestInterface; 7use Sabre\HTTP\ResponseInterface; 8 9/** 10 * This is a simple plugin that will map any GET request for non-files to 11 * PROPFIND allprops-requests. 12 * 13 * This should allow easy debugging of PROPFIND 14 * 15 * @copyright Copyright (C) fruux GmbH (https://fruux.com/) 16 * @author Evert Pot (http://evertpot.com/) 17 * @license http://sabre.io/license/ Modified BSD License 18 */ 19class MapGetToPropFind extends DAV\ServerPlugin { 20 21 /** 22 * reference to server class 23 * 24 * @var DAV\Server 25 */ 26 protected $server; 27 28 /** 29 * Initializes the plugin and subscribes to events 30 * 31 * @param DAV\Server $server 32 * @return void 33 */ 34 function initialize(DAV\Server $server) { 35 36 $this->server = $server; 37 $this->server->on('method:GET', [$this, 'httpGet'], 90); 38 } 39 40 /** 41 * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request 42 * 43 * @param RequestInterface $request 44 * @param ResponseInterface $response 45 * @return bool 46 */ 47 function httpGet(RequestInterface $request, ResponseInterface $response) { 48 49 $node = $this->server->tree->getNodeForPath($request->getPath()); 50 if ($node instanceof DAV\IFile) return; 51 52 $subRequest = clone $request; 53 $subRequest->setMethod('PROPFIND'); 54 55 $this->server->invokeMethod($subRequest, $response); 56 return false; 57 58 } 59 60} 61