introducing Entity interfaces and a File one as first implementation

also adds admin settings that pass entities as initial state

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-08-09 13:24:48 +02:00
parent 9a6f7cc8cb
commit 804d4fe69f
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
15 changed files with 571 additions and 27 deletions

View File

@ -20,7 +20,11 @@ return array(
'OCA\\WorkflowEngine\\Controller\\FlowOperations' => $baseDir . '/../lib/Controller/FlowOperations.php',
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => $baseDir . '/../lib/Controller/GlobalWorkflowsController.php',
'OCA\\WorkflowEngine\\Controller\\RequestTime' => $baseDir . '/../lib/Controller/RequestTime.php',
'OCA\\WorkflowEngine\\Entity\\File' => $baseDir . '/../lib/Entity/File.php',
'OCA\\WorkflowEngine\\Entity\\GenericEntityEmitterEvent' => $baseDir . '/../lib/Entity/GenericEntityEmitterEvent.php',
'OCA\\WorkflowEngine\\Entity\\IEntityEmitterEvent' => $baseDir . '/../lib/Entity/IEntityEmitterEvent.php',
'OCA\\WorkflowEngine\\Manager' => $baseDir . '/../lib/Manager.php',
'OCA\\WorkflowEngine\\Migration\\Version2019Date20190808074233' => $baseDir . '/../lib/Migration/Version2019Date20190808074233.php',
'OCA\\WorkflowEngine\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
'OCA\\WorkflowEngine\\Settings\\Section' => $baseDir . '/../lib/Settings/Section.php',
);

View File

@ -35,8 +35,12 @@ class ComposerStaticInitWorkflowEngine
'OCA\\WorkflowEngine\\Controller\\FlowOperations' => __DIR__ . '/..' . '/../lib/Controller/FlowOperations.php',
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/GlobalWorkflowsController.php',
'OCA\\WorkflowEngine\\Controller\\RequestTime' => __DIR__ . '/..' . '/../lib/Controller/RequestTime.php',
'OCA\\WorkflowEngine\\Entity\\File' => __DIR__ . '/..' . '/../lib/Entity/File.php',
'OCA\\WorkflowEngine\\Entity\\GenericEntityEmitterEvent' => __DIR__ . '/..' . '/../lib/Entity/GenericEntityEmitterEvent.php',
'OCA\\WorkflowEngine\\Entity\\IEntityEmitterEvent' => __DIR__ . '/..' . '/../lib/Entity/IEntityEmitterEvent.php',
'OCA\\WorkflowEngine\\Manager' => __DIR__ . '/..' . '/../lib/Manager.php',
'OCA\\WorkflowEngine\\Migration\\Version2019Date20190808074233' => __DIR__ . '/..' . '/../lib/Migration/Version2019Date20190808074233.php',
'OCA\\WorkflowEngine\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
'OCA\\WorkflowEngine\\Settings\\Section' => __DIR__ . '/..' . '/../lib/Settings/Section.php',
);

View File

@ -27,8 +27,10 @@ use OCA\WorkflowEngine\Controller\FlowOperations;
class Application extends \OCP\AppFramework\App {
const APP_ID = 'workflowengine';
public function __construct() {
parent::__construct('workflowengine');
parent::__construct(self::APP_ID);
$this->getContainer()->registerAlias('FlowOperationsController', FlowOperations::class);
$this->getContainer()->registerAlias('RequestTimeController', RequestTime::class);
@ -47,7 +49,7 @@ class Application extends \OCP\AppFramework\App {
class_exists(Template::class, true);
}
style('workflowengine', [
style(self::APP_ID, [
'admin',
]);
@ -59,7 +61,7 @@ class Application extends \OCP\AppFramework\App {
'systemtags/systemtagscollection',
]);
script('workflowengine', [
script(self::APP_ID, [
'workflowengine',
]);
},

View File

@ -0,0 +1,68 @@
<?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/>.
*
*/
namespace OCA\WorkflowEngine\Entity;
use OCP\Files\IRootFolder;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\WorkflowEngine\IEntity;
class File implements IEntity {
/** @var IL10N */
protected $l10n;
/** @var IURLGenerator */
protected $urlGenerator;
public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) {
$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
}
public function getId(): string {
return 'WorkflowEngine_Entity_File';
}
public function getName(): string {
return $this->l10n->t('File');
}
public function getIcon(): string {
return $this->urlGenerator->imagePath('core', 'categories/files.svg');
}
public function getEvents(): array {
$emitterClass = IRootFolder::class;
$slot = '\OC\Files';
return [
new GenericEntityEmitterEvent($emitterClass, $slot, 'postCreate', $this->l10n->t('File created')),
new GenericEntityEmitterEvent($emitterClass, $slot, 'postWrite', $this->l10n->t('File updated')),
new GenericEntityEmitterEvent($emitterClass, $slot, 'postRename', $this->l10n->t('File renamed')),
new GenericEntityEmitterEvent($emitterClass, $slot, 'postDelete', $this->l10n->t('File deleted')),
new GenericEntityEmitterEvent($emitterClass, $slot, 'postTouch', $this->l10n->t('File accessed')),
new GenericEntityEmitterEvent($emitterClass, $slot, 'postCopy', $this->l10n->t('File copied')),
];
}
}

View File

@ -0,0 +1,59 @@
<?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/>.
*
*/
namespace OCA\WorkflowEngine\Entity;
class GenericEntityEmitterEvent implements IEntityEmitterEvent {
/** @var string */
private $emitterClassName;
/** @var string */
private $eventName;
/** @var string */
private $displayName;
/** @var string */
private $slot;
public function __construct(string $emitterClassName, string $slot, string $eventName, string $displayName) {
$this->emitterClassName = $emitterClassName;
$this->eventName = $eventName;
$this->displayName = $displayName;
$this->slot = $slot;
}
public function getEmitterClassName(): string {
return $this->emitterClassName;
}
public function getSlot(): string {
return $this->slot;
}
public function getDisplayName(): string {
return $this->displayName;
}
public function getEventName(): string {
return $this->eventName;
}
}

View File

@ -0,0 +1,34 @@
<?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/>.
*
*/
namespace OCA\WorkflowEngine\Entity;
use OCP\WorkflowEngine\IEntityEvent;
interface IEntityEmitterEvent extends IEntityEvent {
public function getEmitterClassName(): string;
public function getSlot(): string;
}

View File

@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine;
use OC\Files\Storage\Wrapper\Jail;
use OCA\WorkflowEngine\Entity\File;
use OCP\AppFramework\QueryException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Storage\IStorage;
@ -31,9 +32,12 @@ use OCP\IL10N;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\WorkflowEngine\ICheck;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityAware;
use OCP\WorkflowEngine\IManager;
use OCP\WorkflowEngine\IOperation;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class Manager implements IManager, IEntityAware {
@ -61,15 +65,32 @@ class Manager implements IManager, IEntityAware {
/** @var IL10N */
protected $l;
/** @var EventDispatcherInterface */
protected $eventDispatcher;
/** @var IEntity[] */
protected $registeredEntities = [];
/** @var ILogger */
protected $logger;
/**
* @param IDBConnection $connection
* @param IServerContainer $container
* @param IL10N $l
*/
public function __construct(IDBConnection $connection, IServerContainer $container, IL10N $l) {
public function __construct(
IDBConnection $connection,
IServerContainer $container,
IL10N $l,
EventDispatcherInterface $eventDispatcher,
ILogger $logger
) {
$this->connection = $connection;
$this->container = $container;
$this->l = $l;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
}
/**
@ -414,4 +435,37 @@ class Manager implements IManager, IEntityAware {
}
$this->entity = $entity;
}
/**
* @return IEntity[]
*/
public function getEntitiesList() {
$this->eventDispatcher->dispatch('OCP\WorkflowEngine::registerEntities', new GenericEvent($this));
return array_merge($this->getBuildInEntities(), $this->registeredEntities);
}
/**
* Listen to 'OCP/WorkflowEngine::registerEntities' at the EventDispatcher
* for registering your entities
*
* @since 18.0.0
*/
public function registerEntity(IEntity $entity): void {
$this->registeredEntities[$entity->getId()] = $entity;
}
/**
* @return IEntity[]
*/
protected function getBuildInEntities(): array {
try {
return [
$this->container->query(File::class),
];
} catch (QueryException $e) {
$this->logger->logException($e);
return [];
}
}
}

View File

@ -0,0 +1,126 @@
<?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/>.
*
*/
namespace OCA\WorkflowEngine\Settings;
use OCA\WorkflowEngine\AppInfo\Application;
use OCA\WorkflowEngine\Manager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\Settings\ISettings;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class Admin implements ISettings {
/** @var IL10N */
private $l10n;
/** @var string */
private $appName;
/** @var EventDispatcherInterface */
private $eventDispatcher;
/** @var Manager */
private $manager;
/** @var IInitialStateService */
private $initialStateService;
/**
* @param string $appName
* @param IL10N $l
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(
$appName,
IL10N $l,
EventDispatcherInterface $eventDispatcher,
Manager $manager,
IInitialStateService $initialStateService
) {
$this->appName = $appName;
$this->l10n = $l;
$this->eventDispatcher = $eventDispatcher;
$this->manager = $manager;
$this->initialStateService = $initialStateService;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$this->eventDispatcher->dispatch('OCP\WorkflowEngine::loadAdditionalSettingScripts');
$entities = $this->manager->getEntitiesList();
$this->initialStateService->provideInitialState(
Application::APP_ID,
'entities',
$this->entitiesToArray($entities)
);
return new TemplateResponse(Application::APP_ID, 'admin', [], 'blank');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'workflow';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
private function entitiesToArray(array $entities) {
return array_map(function (IEntity $entity) {
$events = array_map(function(IEntityEvent $entityEvent) {
return [
'eventName' => $entityEvent->getEventName(),
'displayName' => $entityEvent->getDisplayName()
];
}, $entity->getEvents());
return [
'id' => $entity->getId(),
'icon' => $entity->getIcon(),
'name' => $entity->getName(),
'events' => $events,
];
}, $entities);
}
}

View File

@ -22,22 +22,4 @@
/** @var array $_ */
/** @var \OCP\IL10N $l */
?>
<div id="<?php p($_['appid']); ?>" class="section workflowengine">
<h2 class="inlineblock"><?php p($_['heading']); ?></h2>
<?php if (!empty($_['docs'])): ?>
<a target="_blank" rel="noreferrer noopener" class="icon-info svg"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs($_['docs'])); ?>">
</a>
<?php endif; ?>
<?php if (!empty($_['settings-hint'])): ?>
<p class="settings-hint"><?php p($_['settings-hint']); ?></p>
<?php endif; ?>
<?php if (!empty($_['description'])): ?>
<p><?php p($_['description']); ?></p>
<?php endif; ?>
<div class="rules"><span class="icon-loading-small"></span> <?php p($l->t('Loading…')); ?></div>
</div>
<div id="<?php p($_['appid']); ?>" class="<? p(\OCA\WorkflowEngine\AppInfo\Application::APP_ID); ?>"></div>

View File

@ -22,10 +22,15 @@
namespace OCA\WorkflowEngine\Tests;
use OCA\WorkflowEngine\Entity\File;
use OCA\WorkflowEngine\Manager;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\WorkflowEngine\IEntity;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
/**
@ -38,24 +43,36 @@ class ManagerTest extends TestCase {
/** @var Manager */
protected $manager;
/** @var IDBConnection */
/** @var MockObject|IDBConnection */
protected $db;
/** @var \PHPUnit\Framework\MockObject\MockObject|ILogger */
protected $logger;
/** @var \PHPUnit\Framework\MockObject\MockObject|EventDispatcherInterface */
protected $eventDispatcher;
/** @var MockObject|IServerContainer */
protected $container;
protected function setUp() {
parent::setUp();
$this->db = \OC::$server->getDatabaseConnection();
$container = $this->createMock(IServerContainer::class);
$this->container = $this->createMock(IServerContainer::class);
/** @var IL10N|MockObject $l */
$l = $this->createMock(IL10N::class);
$l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
return vsprintf($text, $parameters);
}));
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->logger = $this->createMock(ILogger::class);
$this->manager = new Manager(
\OC::$server->getDatabaseConnection(),
$container,
$l
$this->container,
$l,
$this->eventDispatcher,
$this->logger
);
$this->clearChecks();
}
@ -91,4 +108,50 @@ class ManagerTest extends TestCase {
$this->assertArrayNotHasKey($check1, $data);
$this->assertArrayHasKey($check2, $data);
}
public function testGetEntitiesListBuildInOnly() {
$fileEntityMock = $this->createMock(File::class);
$this->container->expects($this->once())
->method('query')
->with(File::class)
->willReturn($fileEntityMock);
$entities = $this->manager->getEntitiesList();
$this->assertCount(1, $entities);
$this->assertInstanceOf(IEntity::class, $entities[0]);
}
public function testGetEntitiesList() {
$fileEntityMock = $this->createMock(File::class);
$this->container->expects($this->once())
->method('query')
->with(File::class)
->willReturn($fileEntityMock);
/** @var MockObject|IEntity $extraEntity */
$extraEntity = $this->createMock(IEntity::class);
$this->eventDispatcher->expects($this->once())
->method('dispatch')
->with('OCP\WorkflowEngine::registerEntities', $this->anything())
->willReturnCallback(function() use ($extraEntity) {
$this->manager->registerEntity($extraEntity);
});
$entities = $this->manager->getEntitiesList();
$this->assertCount(2, $entities);
$entityTypeCounts = array_reduce($entities, function (array $carry, IEntity $entity) {
if($entity instanceof File) $carry[0]++;
else if($entity instanceof IEntity) $carry[1]++;
return $carry;
}, [0, 0]);
$this->assertSame(1, $entityTypeCounts[0]);
$this->assertSame(1, $entityTypeCounts[1]);
}
}

View File

@ -439,7 +439,9 @@ return array(
'OCP\\User\\Backend\\ISetPasswordBackend' => $baseDir . '/lib/public/User/Backend/ISetPasswordBackend.php',
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\ICheck' => $baseDir . '/lib/public/WorkflowEngine/ICheck.php',
'OCP\\WorkflowEngine\\IEntity' => $baseDir . '/lib/public/WorkflowEngine/IEntity.php',
'OCP\\WorkflowEngine\\IEntityAware' => $baseDir . '/lib/public/WorkflowEngine/IEntityAware.php',
'OCP\\WorkflowEngine\\IEntityEvent' => $baseDir . '/lib/public/WorkflowEngine/IEntityEvent.php',
'OCP\\WorkflowEngine\\IManager' => $baseDir . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => $baseDir . '/lib/public/WorkflowEngine/IOperation.php',
'OC\\Accounts\\Account' => $baseDir . '/lib/private/Accounts/Account.php',

View File

@ -473,7 +473,9 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\User\\Backend\\ISetPasswordBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ISetPasswordBackend.php',
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\ICheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/ICheck.php',
'OCP\\WorkflowEngine\\IEntity' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntity.php',
'OCP\\WorkflowEngine\\IEntityAware' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityAware.php',
'OCP\\WorkflowEngine\\IEntityEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityEvent.php',
'OCP\\WorkflowEngine\\IManager' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperation.php',
'OC\\Accounts\\Account' => __DIR__ . '/../../..' . '/lib/private/Accounts/Account.php',

View File

@ -0,0 +1,84 @@
<?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/>.
*
*/
namespace OCP\WorkflowEngine;
/**
* Interface IEntity
*
* This interface represents an entity that supports events the workflow engine
* can listen to. For example a file with the create, update, etc. events.
*
* Ensure to listen to 'OCP/WorkflowEngine::loadEntities' for registering your
* entities.
*
* @package OCP\WorkflowEngine
* @since 18.0.0
*/
interface IEntity {
/**
* returns a unique ID of the entity.
*
* It can be, but does not need to be the class name of the entitiy. Beware
* that it will be referenced in the database when rules are established,
* so it should not change over the course of the app life.
*
* Example 1: "OCA/MyApp/Entity/Cat"
* Example 2: "myapp_Cats"
*
* @since 18.0.0
*/
public function getId(): string;
/**
* returns a translated name to be presented in the web interface.
*
* Example: "File" (en), "Dosiero" (eo)
*
* @since 18.0.0
*/
public function getName(): string;
/**
* returns the URL to the icon of the entity for display in the web interface.
*
* Usually, the implementation would utilize the `imagePath()` method of the
* `\OCP\IURLGenerator` instance and simply return its result.
*
* Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg');
*
* @since 18.0.0
*/
public function getIcon(): string;
/**
* returns a list of supported events
*
* @return IEntityEvent[]
* @since 18.0.0
*/
public function getEvents(): array;
}

View File

@ -0,0 +1,52 @@
<?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/>.
*
*/
namespace OCP\WorkflowEngine;
/**
* Interface IEntityEvent
*
* represents an entitiy event that is dispatched via EventDispatcher
*
* @package OCP\WorkflowEngine
*/
interface IEntityEvent {
/**
* returns a translated name to be presented in the web interface.
*
* Example: "created" (en), "kreita" (eo)
*
* @since 18.0.0
*/
public function getDisplayName(): string;
/**
* returns the event name that is emitted by the EventDispatcher, e.g.:
*
* Example: "OCA\MyApp\Factory\Cats::postCreated"
*
* @since 18.0.0
*/
public function getEventName(): string;
}

View File

@ -47,4 +47,12 @@ interface IManager {
* @since 9.1
*/
public function getMatchingOperations($class, $returnFirstMatchingOperationOnly = true);
/**
* Listen to 'OCP/WorkflowEngine::registerEntities' at the EventDispatcher
* for registering your entities
*
* @since 18.0.0
*/
public function registerEntity(IEntity $entity): void;
}