diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-02-01 12:19:48 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-02-02 09:57:42 +0100 |
commit | d5126b1ad43377ebbb0f4fc2d7c43267fd5e6672 (patch) | |
tree | e602854de7b4c0d55fe2878fc5f2fffc8fdf5e6b /lib/public/systemtag | |
parent | 591613fce222d1902ac9d981ca6ae99e5aea23cc (diff) | |
download | nextcloud-server-d5126b1ad43377ebbb0f4fc2d7c43267fd5e6672.tar.gz nextcloud-server-d5126b1ad43377ebbb0f4fc2d7c43267fd5e6672.zip |
Dispatch events when tags are added/updated/deleted
Diffstat (limited to 'lib/public/systemtag')
-rw-r--r-- | lib/public/systemtag/managerevent.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/public/systemtag/managerevent.php b/lib/public/systemtag/managerevent.php new file mode 100644 index 00000000000..a0429fc9f67 --- /dev/null +++ b/lib/public/systemtag/managerevent.php @@ -0,0 +1,85 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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/> + * + */ + +namespace OCP\SystemTag; + +use Symfony\Component\EventDispatcher\Event; + +/** + * Class ManagerEvent + * + * @package OCP\SystemTag + * @since 9.0.0 + */ +class ManagerEvent extends Event { + + const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag'; + const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag'; + const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag'; + + /** @var string */ + protected $event; + /** @var ISystemTag */ + protected $tag; + /** @var ISystemTag */ + protected $beforeTag; + + /** + * DispatcherEvent constructor. + * + * @param string $event + * @param ISystemTag $tag + * @param ISystemTag $beforeTag + * @since 9.0.0 + */ + public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) { + $this->event = $event; + $this->tag = $tag; + $this->beforeTag = $beforeTag; + } + + /** + * @return string + * @since 9.0.0 + */ + public function getEvent() { + return $this->event; + } + + /** + * @return ISystemTag + * @since 9.0.0 + */ + public function getTag() { + return $this->tag; + } + + /** + * @return ISystemTag + * @since 9.0.0 + */ + public function getTagBefore() { + if ($this->event !== self::EVENT_UPDATE) { + throw new \BadMethodCallException('getTagBefore is only available on the update Event'); + } + return $this->beforeTag; + } +} |