diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-04-22 15:21:15 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-05-28 12:35:45 +0200 |
commit | 6aa6ab3e02c1ab50992c824b85ecc1a45988379c (patch) | |
tree | d09f950d2905d24497cea60fe3042dd2f62f89a1 /lib/public/Files | |
parent | 1d469fc06e6a6755dbb5543b33fecb9ff2b57340 (diff) | |
download | nextcloud-server-6aa6ab3e02c1ab50992c824b85ecc1a45988379c.tar.gz nextcloud-server-6aa6ab3e02c1ab50992c824b85ecc1a45988379c.zip |
Add lazy events for the Node API
Right now if you want to get events via the Node API you have to have a
real instance of the Root. Which in turns sets up the whole FS.
We should make sure this is done lazy. Else enabling the preview
generator for example makes you setup the whole FS on each and every
authenticated call.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/public/Files')
-rw-r--r-- | lib/public/Files/Events/Node/AbstractNodeEvent.php | 52 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/AbstractNodesEvent.php | 62 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeCopiedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeCreatedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeReadEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeTouchedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/BeforeNodeWrittenEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeCopiedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeCreatedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeDeletedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeRenamedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeTouchedEvent.php | 32 | ||||
-rw-r--r-- | lib/public/Files/Events/Node/NodeWrittenEvent.php | 32 |
15 files changed, 530 insertions, 0 deletions
diff --git a/lib/public/Files/Events/Node/AbstractNodeEvent.php b/lib/public/Files/Events/Node/AbstractNodeEvent.php new file mode 100644 index 00000000000..a6976e36397 --- /dev/null +++ b/lib/public/Files/Events/Node/AbstractNodeEvent.php @@ -0,0 +1,52 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +use OCP\EventDispatcher\Event; +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; + } + + /** + * @since 20.0.0 + */ + public function getNode(): Node { + return $this->node; + } +} diff --git a/lib/public/Files/Events/Node/AbstractNodesEvent.php b/lib/public/Files/Events/Node/AbstractNodesEvent.php new file mode 100644 index 00000000000..b5500143d7d --- /dev/null +++ b/lib/public/Files/Events/Node/AbstractNodesEvent.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +use OCP\EventDispatcher\Event; +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; + } + + /** + * @since 20.0.0 + */ + public function getSource(): Node { + return $this->source; + } + + /** + * @since 20.0.0 + */ + public function getTarget(): Node { + return $this->target; + } +} diff --git a/lib/public/Files/Events/Node/BeforeNodeCopiedEvent.php b/lib/public/Files/Events/Node/BeforeNodeCopiedEvent.php new file mode 100644 index 00000000000..258d8b61bfc --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeCopiedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeCopiedEvent extends AbstractNodesEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeCreatedEvent.php b/lib/public/Files/Events/Node/BeforeNodeCreatedEvent.php new file mode 100644 index 00000000000..645ea26a747 --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeCreatedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeCreatedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php new file mode 100644 index 00000000000..cd71de981ad --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeDeletedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeReadEvent.php b/lib/public/Files/Events/Node/BeforeNodeReadEvent.php new file mode 100644 index 00000000000..59bb8a0711c --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeReadEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeReadEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php new file mode 100644 index 00000000000..f4eeff0ce53 --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeRenamedEvent extends AbstractNodesEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeTouchedEvent.php b/lib/public/Files/Events/Node/BeforeNodeTouchedEvent.php new file mode 100644 index 00000000000..690c2ebe13f --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeTouchedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeTouchedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/BeforeNodeWrittenEvent.php b/lib/public/Files/Events/Node/BeforeNodeWrittenEvent.php new file mode 100644 index 00000000000..03c458d9fcb --- /dev/null +++ b/lib/public/Files/Events/Node/BeforeNodeWrittenEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class BeforeNodeWrittenEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/NodeCopiedEvent.php b/lib/public/Files/Events/Node/NodeCopiedEvent.php new file mode 100644 index 00000000000..3b607caa2c8 --- /dev/null +++ b/lib/public/Files/Events/Node/NodeCopiedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeCopiedEvent extends AbstractNodesEvent { +} diff --git a/lib/public/Files/Events/Node/NodeCreatedEvent.php b/lib/public/Files/Events/Node/NodeCreatedEvent.php new file mode 100644 index 00000000000..2b2bfa4ea90 --- /dev/null +++ b/lib/public/Files/Events/Node/NodeCreatedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeCreatedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/NodeDeletedEvent.php b/lib/public/Files/Events/Node/NodeDeletedEvent.php new file mode 100644 index 00000000000..473c66bcbbf --- /dev/null +++ b/lib/public/Files/Events/Node/NodeDeletedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeDeletedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/NodeRenamedEvent.php b/lib/public/Files/Events/Node/NodeRenamedEvent.php new file mode 100644 index 00000000000..e82e0b0a321 --- /dev/null +++ b/lib/public/Files/Events/Node/NodeRenamedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeRenamedEvent extends AbstractNodesEvent { +} diff --git a/lib/public/Files/Events/Node/NodeTouchedEvent.php b/lib/public/Files/Events/Node/NodeTouchedEvent.php new file mode 100644 index 00000000000..7ac53266f3f --- /dev/null +++ b/lib/public/Files/Events/Node/NodeTouchedEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeTouchedEvent extends AbstractNodeEvent { +} diff --git a/lib/public/Files/Events/Node/NodeWrittenEvent.php b/lib/public/Files/Events/Node/NodeWrittenEvent.php new file mode 100644 index 00000000000..f8eafe54bb8 --- /dev/null +++ b/lib/public/Files/Events/Node/NodeWrittenEvent.php @@ -0,0 +1,32 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events\Node; + +/** + * @since 20.0.0 + */ +class NodeWrittenEvent extends AbstractNodeEvent { +} |