2019-08-09 07:24:48 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2019-08-09 07:24:48 -04:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2019-08-09 07:24:48 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-08-09 07:24:48 -04:00
|
|
|
*/
|
2019-09-03 06:31:29 -04:00
|
|
|
namespace OCP\WorkflowEngine;
|
|
|
|
|
|
2019-09-09 11:23:22 -04:00
|
|
|
/**
|
|
|
|
|
* Class GenericEntityEvent
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2019-09-03 06:31:29 -04:00
|
|
|
class GenericEntityEvent implements IEntityEvent {
|
2019-08-09 07:24:48 -04:00
|
|
|
/** @var string */
|
|
|
|
|
private $displayName;
|
|
|
|
|
/** @var string */
|
2019-09-03 06:31:29 -04:00
|
|
|
private $eventName;
|
2019-08-09 07:24:48 -04:00
|
|
|
|
2019-09-09 11:23:22 -04:00
|
|
|
/**
|
|
|
|
|
* GenericEntityEvent constructor.
|
|
|
|
|
*
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2019-09-03 06:31:29 -04:00
|
|
|
public function __construct(string $displayName, string $eventName) {
|
2020-04-10 08:19:56 -04:00
|
|
|
if (trim($displayName) === '') {
|
2019-09-03 06:31:29 -04:00
|
|
|
throw new \InvalidArgumentException('DisplayName must not be empty');
|
|
|
|
|
}
|
2020-04-10 08:19:56 -04:00
|
|
|
if (trim($eventName) === '') {
|
2019-09-03 06:31:29 -04:00
|
|
|
throw new \InvalidArgumentException('EventName must not be empty');
|
|
|
|
|
}
|
2019-08-09 07:24:48 -04:00
|
|
|
|
2019-09-03 06:31:29 -04:00
|
|
|
$this->displayName = trim($displayName);
|
|
|
|
|
$this->eventName = trim($eventName);
|
2019-08-09 07:24:48 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-03 06:31:29 -04:00
|
|
|
/**
|
|
|
|
|
* returns a translated name to be presented in the web interface.
|
|
|
|
|
*
|
|
|
|
|
* Example: "created" (en), "kreita" (eo)
|
|
|
|
|
*
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2019-08-09 07:24:48 -04:00
|
|
|
public function getDisplayName(): string {
|
2019-09-06 05:44:45 -04:00
|
|
|
return $this->displayName;
|
2019-08-09 07:24:48 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-03 06:31:29 -04:00
|
|
|
/**
|
|
|
|
|
* returns the event name that is emitted by the EventDispatcher, e.g.:
|
|
|
|
|
*
|
|
|
|
|
* Example: "OCA\MyApp\Factory\Cats::postCreated"
|
|
|
|
|
*
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2019-08-09 07:24:48 -04:00
|
|
|
public function getEventName(): string {
|
2019-09-06 05:44:45 -04:00
|
|
|
return $this->eventName;
|
2019-08-09 07:24:48 -04:00
|
|
|
}
|
|
|
|
|
}
|