1<?php 2/** 3 * @author Viktar Dubiniuk <dubiniuk@owncloud.com> 4 * 5 * @copyright Copyright (c) 2018, ownCloud GmbH 6 * @license AGPL-3.0 7 * 8 * This code is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License, version 3, 10 * as published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Affero General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License, version 3, 18 * along with this program. If not, see <http://www.gnu.org/licenses/> 19 * 20 */ 21 22namespace OCA\DAV\DAV; 23 24use Sabre\DAV\PropertyStorage\Plugin; 25use Sabre\DAV\Server; 26 27/** 28 * Class FileCustomPropertiesPlugin 29 * 30 * Provides ability to store/retrieve fileId and path before deleting 31 * the node from tree otherwise it will not be possible to resolve the path by 32 * fileId in the backend and delete properties for this fileId 33 * 34 * @package OCA\DAV\DAV 35 */ 36class FileCustomPropertiesPlugin extends Plugin { 37 /** 38 * @param Server $server 39 * 40 * @return void 41 */ 42 public function initialize(Server $server) { 43 $server->on('beforeUnbind', [$this, 'beforeUnbind'], 90); 44 parent::initialize($server); 45 } 46 47 /** 48 * Store fileId before deletion 49 * 50 * @param string $path 51 * 52 * @return void 53 */ 54 public function beforeUnbind($path) { 55 $pathFilter = $this->pathFilter; 56 if ($pathFilter && !$pathFilter($path)) { 57 return; 58 } 59 '@phan-var \OCA\DAV\DAV\FileCustomPropertiesBackend $this->backend'; 60 $this->backend->beforeDelete($path); 61 } 62} 63