From 467c84ec53511b008c7d6ac0888645a381787288 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 8 Mar 2024 13:08:57 -0100 Subject: feat(files): copy live photos Signed-off-by: Maxence Lange --- lib/public/Exceptions/AbortedEventException.php | 34 ++++++++++++++++++++++ lib/public/Files/Events/Node/AbstractNodeEvent.php | 8 ++--- .../Files/Events/Node/AbstractNodesEvent.php | 12 +++----- .../Files/Events/Node/BeforeNodeDeletedEvent.php | 20 ++----------- .../Files/Events/Node/BeforeNodeRenamedEvent.php | 20 ++----------- 5 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 lib/public/Exceptions/AbortedEventException.php (limited to 'lib/public') diff --git a/lib/public/Exceptions/AbortedEventException.php b/lib/public/Exceptions/AbortedEventException.php new file mode 100644 index 00000000000..5a3b797e386 --- /dev/null +++ b/lib/public/Exceptions/AbortedEventException.php @@ -0,0 +1,34 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + +namespace OCP\Exceptions; + +use Exception; + +/** + * @since 29.0.0 + */ +class AbortedEventException extends Exception { +} diff --git a/lib/public/Files/Events/Node/AbstractNodeEvent.php b/lib/public/Files/Events/Node/AbstractNodeEvent.php index d6c1c6d0f95..768c0eda2d5 100644 --- a/lib/public/Files/Events/Node/AbstractNodeEvent.php +++ b/lib/public/Files/Events/Node/AbstractNodeEvent.php @@ -32,14 +32,12 @@ use OCP\Files\Node; * @since 20.0.0 */ abstract class AbstractNodeEvent extends Event { - /** @var Node */ - private $node; - /** * @since 20.0.0 */ - public function __construct(Node $node) { - $this->node = $node; + public function __construct( + private Node $node + ) { } /** diff --git a/lib/public/Files/Events/Node/AbstractNodesEvent.php b/lib/public/Files/Events/Node/AbstractNodesEvent.php index 6bd9bc32a88..d736ebf1635 100644 --- a/lib/public/Files/Events/Node/AbstractNodesEvent.php +++ b/lib/public/Files/Events/Node/AbstractNodesEvent.php @@ -32,17 +32,13 @@ use OCP\Files\Node; * @since 20.0.0 */ abstract class AbstractNodesEvent extends Event { - /** @var Node */ - private $source; - /** @var Node */ - private $target; - /** * @since 20.0.0 */ - public function __construct(Node $source, Node $target) { - $this->source = $source; - $this->target = $target; + public function __construct( + private Node $source, + private Node $target + ) { } /** diff --git a/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php index dd29a39a279..c0226a9b527 100644 --- a/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php +++ b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php @@ -25,31 +25,17 @@ declare(strict_types=1); */ namespace OCP\Files\Events\Node; -use Exception; -use OCP\Files\Node; +use OCP\Exceptions\AbortedEventException; /** * @since 20.0.0 */ class BeforeNodeDeletedEvent extends AbstractNodeEvent { - /** - * @since 20.0.0 - */ - public function __construct(Node $node, private bool &$run) { - parent::__construct($node); - } - /** * @since 28.0.0 - * @return never + * @deprecated 29.0.0 - use OCP\Exceptions\AbortedEventException instead */ public function abortOperation(\Throwable $ex = null) { - $this->stopPropagation(); - $this->run = false; - if ($ex !== null) { - throw $ex; - } else { - throw new Exception('Operation aborted'); - } + throw new AbortedEventException($ex?->getMessage() ?? 'Operation aborted'); } } diff --git a/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php index c6876666713..4c2c566c8c6 100644 --- a/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php +++ b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php @@ -25,31 +25,17 @@ declare(strict_types=1); */ namespace OCP\Files\Events\Node; -use Exception; -use OCP\Files\Node; +use OCP\Exceptions\AbortedEventException; /** * @since 20.0.0 */ class BeforeNodeRenamedEvent extends AbstractNodesEvent { - /** - * @since 20.0.0 - */ - public function __construct(Node $source, Node $target, private bool &$run) { - parent::__construct($source, $target); - } - /** * @since 28.0.0 - * @return never + * @deprecated 29.0.0 - use OCP\Exceptions\AbortedEventException instead */ public function abortOperation(\Throwable $ex = null) { - $this->stopPropagation(); - $this->run = false; - if ($ex !== null) { - throw $ex; - } else { - throw new Exception('Operation aborted'); - } + throw new AbortedEventException($ex?->getMessage() ?? 'Operation aborted'); } } -- cgit v1.2.3