2019-08-09 14:24:48 +03:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
*
|
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-09-03 13:31:29 +03:00
|
|
|
namespace OCP\WorkflowEngine;
|
|
|
|
|
2019-09-09 18:23:22 +03:00
|
|
|
/**
|
|
|
|
* Class GenericEntityEvent
|
|
|
|
*
|
|
|
|
* @package OCP\WorkflowEngine
|
|
|
|
*
|
|
|
|
* @since 18.0.0
|
|
|
|
*/
|
2019-09-03 13:31:29 +03:00
|
|
|
class GenericEntityEvent implements IEntityEvent {
|
2019-08-09 14:24:48 +03:00
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $displayName;
|
|
|
|
/** @var string */
|
2019-09-03 13:31:29 +03:00
|
|
|
private $eventName;
|
2019-08-09 14:24:48 +03:00
|
|
|
|
2019-09-09 18:23:22 +03:00
|
|
|
/**
|
|
|
|
* GenericEntityEvent constructor.
|
|
|
|
*
|
|
|
|
* @since 18.0.0
|
|
|
|
*/
|
2019-09-03 13:31:29 +03:00
|
|
|
public function __construct(string $displayName, string $eventName) {
|
|
|
|
if(trim($displayName) === '') {
|
|
|
|
throw new \InvalidArgumentException('DisplayName must not be empty');
|
|
|
|
}
|
|
|
|
if(trim($eventName) === '') {
|
|
|
|
throw new \InvalidArgumentException('EventName must not be empty');
|
|
|
|
}
|
2019-08-09 14:24:48 +03:00
|
|
|
|
2019-09-03 13:31:29 +03:00
|
|
|
$this->displayName = trim($displayName);
|
|
|
|
$this->eventName = trim($eventName);
|
2019-08-09 14:24:48 +03:00
|
|
|
}
|
|
|
|
|
2019-09-03 13:31:29 +03:00
|
|
|
/**
|
|
|
|
* returns a translated name to be presented in the web interface.
|
|
|
|
*
|
|
|
|
* Example: "created" (en), "kreita" (eo)
|
|
|
|
*
|
|
|
|
* @since 18.0.0
|
|
|
|
*/
|
2019-08-09 14:24:48 +03:00
|
|
|
public function getDisplayName(): string {
|
2019-09-06 12:44:45 +03:00
|
|
|
return $this->displayName;
|
2019-08-09 14:24:48 +03:00
|
|
|
}
|
|
|
|
|
2019-09-03 13:31:29 +03: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 14:24:48 +03:00
|
|
|
public function getEventName(): string {
|
2019-09-06 12:44:45 +03:00
|
|
|
return $this->eventName;
|
2019-08-09 14:24:48 +03:00
|
|
|
}
|
|
|
|
}
|