2013-09-20 16:37:52 +02:00
|
|
|
<?php
|
2019-12-03 19:57:53 +01:00
|
|
|
|
2019-01-24 16:52:38 +01:00
|
|
|
declare(strict_types=1);
|
2013-11-03 13:51:39 +01:00
|
|
|
/**
|
2024-05-23 09:26:56 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-09-20 16:37:52 +02:00
|
|
|
*/
|
|
|
|
namespace OCP\Activity;
|
|
|
|
|
2024-04-17 15:29:33 +02:00
|
|
|
use OCP\Activity\Exceptions\FilterNotFoundException;
|
2024-04-17 13:13:10 +02:00
|
|
|
use OCP\Activity\Exceptions\IncompleteActivityException;
|
2024-04-17 15:29:33 +02:00
|
|
|
use OCP\Activity\Exceptions\SettingNotFoundException;
|
2024-04-17 13:13:10 +02:00
|
|
|
|
2015-04-16 17:00:08 +02:00
|
|
|
/**
|
|
|
|
* Interface IManager
|
|
|
|
*
|
|
|
|
* @since 6.0.0
|
|
|
|
*/
|
2013-09-20 16:37:52 +02:00
|
|
|
interface IManager {
|
2015-08-19 17:37:55 +02:00
|
|
|
/**
|
2015-08-20 15:35:24 +02:00
|
|
|
* Generates a new IEvent object
|
|
|
|
*
|
|
|
|
* Make sure to call at least the following methods before sending it to the
|
|
|
|
* app with via the publish() method:
|
|
|
|
* - setApp()
|
|
|
|
* - setType()
|
|
|
|
* - setAffectedUser()
|
|
|
|
* - setSubject()
|
2020-09-15 10:22:54 +02:00
|
|
|
* - setObject()
|
2015-08-20 15:35:24 +02:00
|
|
|
*
|
2015-08-19 17:37:55 +02:00
|
|
|
* @return IEvent
|
|
|
|
* @since 8.2.0
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function generateEvent(): IEvent;
|
2015-08-19 17:37:55 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-20 15:35:24 +02:00
|
|
|
* Publish an event to the activity consumers
|
|
|
|
*
|
|
|
|
* Make sure to call at least the following methods before sending an Event:
|
|
|
|
* - setApp()
|
|
|
|
* - setType()
|
|
|
|
* - setAffectedUser()
|
|
|
|
* - setSubject()
|
2020-09-15 10:22:54 +02:00
|
|
|
* - setObject()
|
2015-08-20 15:35:24 +02:00
|
|
|
*
|
2015-08-19 17:37:55 +02:00
|
|
|
* @param IEvent $event
|
2024-04-17 13:13:10 +02:00
|
|
|
* @throws IncompleteActivityException if required values have not been set
|
2015-08-19 17:37:55 +02:00
|
|
|
* @since 8.2.0
|
2024-04-17 13:13:10 +02:00
|
|
|
* @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
|
2015-08-19 17:37:55 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function publish(IEvent $event): void;
|
2013-09-20 16:37:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In order to improve lazy loading a closure can be registered which will be called in case
|
|
|
|
* activity consumers are actually requested
|
|
|
|
*
|
2014-07-03 13:48:15 +02:00
|
|
|
* $callable has to return an instance of \OCP\Activity\IConsumer
|
2013-09-20 16:37:52 +02:00
|
|
|
*
|
|
|
|
* @param \Closure $callable
|
2015-04-16 17:00:08 +02:00
|
|
|
* @since 6.0.0
|
2013-09-20 16:37:52 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function registerConsumer(\Closure $callable): void;
|
2014-07-03 13:48:15 +02:00
|
|
|
|
2016-10-20 17:57:44 +02:00
|
|
|
/**
|
|
|
|
* @param string $filter Class must implement OCA\Activity\IFilter
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-10-20 17:57:44 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function registerFilter(string $filter): void;
|
2016-10-20 17:57:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return IFilter[]
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-10-20 17:57:44 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getFilters(): array;
|
2016-10-20 17:57:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $id
|
|
|
|
* @return IFilter
|
2024-04-17 15:29:33 +02:00
|
|
|
* @throws FilterNotFoundException when the filter was not found
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2024-04-17 15:29:33 +02:00
|
|
|
* @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
|
2016-10-20 17:57:44 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getFilterById(string $id): IFilter;
|
2016-10-20 17:57:44 +02:00
|
|
|
|
2016-10-25 18:00:25 +02:00
|
|
|
/**
|
|
|
|
* @param string $setting Class must implement OCA\Activity\ISetting
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-10-25 18:00:25 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function registerSetting(string $setting): void;
|
2016-10-25 18:00:25 +02:00
|
|
|
|
|
|
|
/**
|
2020-06-15 15:01:52 +02:00
|
|
|
* @return ActivitySettings[]
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-10-25 18:00:25 +02:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getSettings(): array;
|
2016-10-25 18:00:25 +02:00
|
|
|
|
2016-11-04 11:33:33 +01:00
|
|
|
/**
|
|
|
|
* @param string $provider Class must implement OCA\Activity\IProvider
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-11-04 11:33:33 +01:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function registerProvider(string $provider): void;
|
2016-11-04 11:33:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return IProvider[]
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2016-11-04 11:33:33 +01:00
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getProviders(): array;
|
2016-11-04 11:33:33 +01:00
|
|
|
|
2016-10-25 18:00:25 +02:00
|
|
|
/**
|
|
|
|
* @param string $id
|
2020-06-15 15:01:52 +02:00
|
|
|
* @return ActivitySettings
|
2024-04-17 15:29:33 +02:00
|
|
|
* @throws SettingNotFoundException when the setting was not found
|
2016-11-16 09:29:27 +01:00
|
|
|
* @since 11.0.0
|
2024-04-17 15:29:33 +02:00
|
|
|
* @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
|
2016-10-25 18:00:25 +02:00
|
|
|
*/
|
2020-06-15 15:01:52 +02:00
|
|
|
public function getSettingById(string $id): ActivitySettings;
|
2014-07-03 13:48:15 +02:00
|
|
|
|
2015-10-02 09:53:39 +02:00
|
|
|
/**
|
|
|
|
* @param string $type
|
|
|
|
* @param int $id
|
|
|
|
* @since 8.2.0
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function setFormattingObject(string $type, int $id): void;
|
2015-10-02 09:53:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
* @since 8.2.0
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function isFormattingFilteredObject(): bool;
|
2015-10-02 09:53:39 +02:00
|
|
|
|
2017-06-20 12:40:45 +02:00
|
|
|
/**
|
|
|
|
* @param bool $status Set to true, when parsing events should not use SVG icons
|
|
|
|
* @since 12.0.1
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function setRequirePNG(bool $status): void;
|
2017-06-20 12:40:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
* @since 12.0.1
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getRequirePNG(): bool;
|
2016-10-20 17:57:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the user we need to use
|
|
|
|
*
|
|
|
|
* @param string|null $currentUserId
|
|
|
|
* @since 9.0.1
|
|
|
|
*/
|
2024-03-28 16:13:19 +01:00
|
|
|
public function setCurrentUserId(?string $currentUserId = null): void;
|
2016-10-20 17:57:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the user we need to use
|
|
|
|
*
|
|
|
|
* Either the user is logged in, or we try to get it from the token
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
|
|
|
|
* @since 8.1.0
|
|
|
|
*/
|
2019-01-24 16:52:38 +01:00
|
|
|
public function getCurrentUserId(): string;
|
2013-09-20 16:37:52 +02:00
|
|
|
}
|