Merge pull request #37040 from nextcloud/techdebt/noid/remove-deprecated-classes

techdebt(workflowengine): Remove transition event classes
enh/trashbin-scan-command
Joas Schilling 1 year ago committed by GitHub
commit e5ee2ec441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,16 +36,14 @@ use OCP\AppFramework\App;
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';
@ -68,10 +66,10 @@ class Application extends App implements IBootstrap {
}
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) {
@ -83,9 +81,9 @@ class Application extends App implements IBootstrap {
$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);
@ -98,16 +96,12 @@ class Application extends App implements IBootstrap {
->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}',
@ -121,8 +115,8 @@ class Application extends App implements IBootstrap {
);
}
$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
}
}
);

@ -429,7 +429,8 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
(self::$includeFile)($file);
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
@ -560,7 +561,10 @@ class ClassLoader
return false;
}
private static function initializeIncludeClosure(): void
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
@ -574,8 +578,8 @@ class ClassLoader
* @param string $file
* @return void
*/
self::$includeFile = static function($file) {
self::$includeFile = \Closure::bind(static function($file) {
include $file;
};
}, null, null);
}
}

@ -649,12 +649,10 @@ return array(
'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',

@ -34,15 +34,15 @@ class ComposerAutoloaderInit749170dad3f5e7f9ca158f5a9f04f6a2
$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;

@ -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',

@ -1,47 +0,0 @@
<?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 IEntityCompat
*
* This interface extends IEntity to provide compatibility with old style
* Event classes. It is only present for a transition period and will be
* removed in 2023 again.
*
* @since 18.0.0
* @deprecated
*/
interface IEntityCompat extends IEntity {
/**
* Like prepareRuleMatcherCompat, but works with events that are not based
* on \OCP\EventDispatcher\Event.
*
* @since 18.0.0
* @deprecated
*/
public function prepareRuleMatcherCompat(IRuleMatcher $ruleMatcher, string $eventName, $event): void;
}

@ -1,50 +0,0 @@
<?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 IOperationCompat
*
* This interface extends IOperation to provide compatibility with old style
* Event classes. It is only present for a transition period and will be
* removed in 2023 again.
*
* @since 18.0.0
* @deprecated
*/
interface IOperationCompat {
/**
* Like onEvent, but used with events that are not based on
* \OCP\EventDispatcher\Event.
*
* This method is introduced for compatibility reasons and will be removed
* in 2023 again.
*
* @since 18.0.0
* @deprecated
*/
public function onEventCompat(string $eventName, $event, IRuleMatcher $ruleMatcher): void;
}
Loading…
Cancel
Save