diff options
Diffstat (limited to 'apps/dav/lib/Comments/RootCollection.php')
-rw-r--r-- | apps/dav/lib/Comments/RootCollection.php | 81 |
1 files changed, 19 insertions, 62 deletions
diff --git a/apps/dav/lib/Comments/RootCollection.php b/apps/dav/lib/Comments/RootCollection.php index e8e890696eb..493d73ec531 100644 --- a/apps/dav/lib/Comments/RootCollection.php +++ b/apps/dav/lib/Comments/RootCollection.php @@ -1,81 +1,35 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\DAV\Comments; use OCP\Comments\CommentsEntityEvent; use OCP\Comments\ICommentsManager; -use OCP\ILogger; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IUserManager; use OCP\IUserSession; +use Psr\Log\LoggerInterface; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotAuthenticated; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ICollection; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; class RootCollection implements ICollection { - /** @var EntityTypeCollection[]|null */ - private $entityTypeCollections; - - /** @var ICommentsManager */ - protected $commentsManager; - - /** @var string */ - protected $name = 'comments'; - - /** @var ILogger */ - protected $logger; + private ?array $entityTypeCollections = null; + protected string $name = 'comments'; - /** @var IUserManager */ - protected $userManager; - - /** @var IUserSession */ - protected $userSession; - - /** @var EventDispatcherInterface */ - protected $dispatcher; - - /** - * @param ICommentsManager $commentsManager - * @param IUserManager $userManager - * @param IUserSession $userSession - * @param EventDispatcherInterface $dispatcher - * @param ILogger $logger - */ public function __construct( - ICommentsManager $commentsManager, - IUserManager $userManager, - IUserSession $userSession, - EventDispatcherInterface $dispatcher, - ILogger $logger) { - $this->commentsManager = $commentsManager; - $this->logger = $logger; - $this->userManager = $userManager; - $this->userSession = $userSession; - $this->dispatcher = $dispatcher; + protected ICommentsManager $commentsManager, + protected IUserManager $userManager, + protected IUserSession $userSession, + protected IEventDispatcher $dispatcher, + protected LoggerInterface $logger, + ) { } /** @@ -94,7 +48,8 @@ class RootCollection implements ICollection { throw new NotAuthenticated(); } - $event = new CommentsEntityEvent(CommentsEntityEvent::EVENT_ENTITY); + $event = new CommentsEntityEvent(); + $this->dispatcher->dispatchTyped($event); $this->dispatcher->dispatch(CommentsEntityEvent::EVENT_ENTITY, $event); $this->entityTypeCollections = []; @@ -157,6 +112,7 @@ class RootCollection implements ICollection { */ public function getChildren() { $this->initCollections(); + assert(!is_null($this->entityTypeCollections)); return $this->entityTypeCollections; } @@ -168,6 +124,7 @@ class RootCollection implements ICollection { */ public function childExists($name) { $this->initCollections(); + assert(!is_null($this->entityTypeCollections)); return isset($this->entityTypeCollections[$name]); } @@ -204,7 +161,7 @@ class RootCollection implements ICollection { /** * Returns the last modification time, as a unix timestamp * - * @return int + * @return ?int */ public function getLastModified() { return null; |