Skip to content

Commit

Permalink
techdebt(workflowengine): Remove transition event classes
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Mar 3, 2023
1 parent de64c96 commit 5bc86dd
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 125 deletions.
28 changes: 11 additions & 17 deletions apps/workflowengine/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityCompat;
use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\IOperationCompat;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class Application extends App implements IBootstrap {
public const APP_ID = 'workflowengine';
Expand All @@ -68,10 +66,10 @@ public function boot(IBootContext $context): void {
}

private function registerRuleListeners(IEventDispatcher $dispatcher,
IServerContainer $container,
ILogger $logger): void {
ContainerInterface $container,
LoggerInterface $logger): void {
/** @var Manager $manager */
$manager = $container->query(Manager::class);
$manager = $container->get(Manager::class);
$configuredEvents = $manager->getAllConfiguredEvents();

foreach ($configuredEvents as $operationClass => $events) {
Expand All @@ -83,9 +81,9 @@ function ($event) use ($manager, $container, $eventName, $logger, $operationClas
$ruleMatcher = $manager->getRuleMatcher();
try {
/** @var IEntity $entity */
$entity = $container->query($entityClass);
$entity = $container->get($entityClass);
/** @var IOperation $operation */
$operation = $container->query($operationClass);
$operation = $container->get($operationClass);

$ruleMatcher->setEventName($eventName);
$ruleMatcher->setEntity($entity);
Expand All @@ -98,16 +96,12 @@ function ($event) use ($manager, $container, $eventName, $logger, $operationClas
->setEventName($eventName);

/** @var Logger $flowLogger */
$flowLogger = $container->query(Logger::class);
$flowLogger = $container->get(Logger::class);
$flowLogger->logEventInit($ctx);

if ($event instanceof Event) {
$entity->prepareRuleMatcher($ruleMatcher, $eventName, $event);
$operation->onEvent($eventName, $event, $ruleMatcher);
} elseif ($entity instanceof IEntityCompat && $operation instanceof IOperationCompat) {
// TODO: Remove this block (and the compat classes) in the first major release in 2023
$entity->prepareRuleMatcherCompat($ruleMatcher, $eventName, $event);
$operation->onEventCompat($eventName, $event, $ruleMatcher);
} else {
$logger->debug(
'Cannot handle event {name} of {event} against entity {entity} and operation {operation}',
Expand All @@ -121,8 +115,8 @@ function ($event) use ($manager, $container, $eventName, $logger, $operationClas
);
}
$flowLogger->logEventDone($ctx);
} catch (QueryException $e) {
// Ignore query exceptions since they might occur when an entity/operation were setup before by an app that is disabled now
} catch (ContainerExceptionInterface $e) {
// Ignore query exceptions since they might occur when an entity/operation were set up before by an app that is disabled now
}
}
);
Expand Down
12 changes: 8 additions & 4 deletions lib/composer/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ public function unregister()
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
(self::$includeFile)($file);
$includeFile = self::$includeFile;
$includeFile($file);

return true;
}
Expand Down Expand Up @@ -560,7 +561,10 @@ private function findFileWithExtension($class, $ext)
return false;
}

private static function initializeIncludeClosure(): void
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
Expand All @@ -574,8 +578,8 @@ private static function initializeIncludeClosure(): void
* @param string $file
* @return void
*/
self::$includeFile = static function($file) {
self::$includeFile = \Closure::bind(static function($file) {
include $file;
};
}, null, null);
}
}
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,10 @@
'OCP\\WorkflowEngine\\IComplexOperation' => $baseDir . '/lib/public/WorkflowEngine/IComplexOperation.php',
'OCP\\WorkflowEngine\\IEntity' => $baseDir . '/lib/public/WorkflowEngine/IEntity.php',
'OCP\\WorkflowEngine\\IEntityCheck' => $baseDir . '/lib/public/WorkflowEngine/IEntityCheck.php',
'OCP\\WorkflowEngine\\IEntityCompat' => $baseDir . '/lib/public/WorkflowEngine/IEntityCompat.php',
'OCP\\WorkflowEngine\\IEntityEvent' => $baseDir . '/lib/public/WorkflowEngine/IEntityEvent.php',
'OCP\\WorkflowEngine\\IFileCheck' => $baseDir . '/lib/public/WorkflowEngine/IFileCheck.php',
'OCP\\WorkflowEngine\\IManager' => $baseDir . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => $baseDir . '/lib/public/WorkflowEngine/IOperation.php',
'OCP\\WorkflowEngine\\IOperationCompat' => $baseDir . '/lib/public/WorkflowEngine/IOperationCompat.php',
'OCP\\WorkflowEngine\\IRuleMatcher' => $baseDir . '/lib/public/WorkflowEngine/IRuleMatcher.php',
'OCP\\WorkflowEngine\\ISpecificOperation' => $baseDir . '/lib/public/WorkflowEngine/ISpecificOperation.php',
'OC\\Accounts\\Account' => $baseDir . '/lib/private/Accounts/Account.php',
Expand Down
6 changes: 3 additions & 3 deletions lib/composer/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public static function getLoader()
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2::$files;
$requireFile = static function ($fileIdentifier, $file) {
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

require $file;
}
};
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
($requireFile)($fileIdentifier, $file);
$requireFile($fileIdentifier, $file);
}

return $loader;
Expand Down
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\WorkflowEngine\\IComplexOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IComplexOperation.php',
'OCP\\WorkflowEngine\\IEntity' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntity.php',
'OCP\\WorkflowEngine\\IEntityCheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityCheck.php',
'OCP\\WorkflowEngine\\IEntityCompat' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityCompat.php',
'OCP\\WorkflowEngine\\IEntityEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityEvent.php',
'OCP\\WorkflowEngine\\IFileCheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IFileCheck.php',
'OCP\\WorkflowEngine\\IManager' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperation.php',
'OCP\\WorkflowEngine\\IOperationCompat' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperationCompat.php',
'OCP\\WorkflowEngine\\IRuleMatcher' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IRuleMatcher.php',
'OCP\\WorkflowEngine\\ISpecificOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/ISpecificOperation.php',
'OC\\Accounts\\Account' => __DIR__ . '/../../..' . '/lib/private/Accounts/Account.php',
Expand Down
47 changes: 0 additions & 47 deletions lib/public/WorkflowEngine/IEntityCompat.php

This file was deleted.

50 changes: 0 additions & 50 deletions lib/public/WorkflowEngine/IOperationCompat.php

This file was deleted.

0 comments on commit 5bc86dd

Please sign in to comment.