Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow to not use deprecated event dispatcher methods #21475

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/workflowengine/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@
use OCA\WorkflowEngine\Helper\LogContext;
use OCA\WorkflowEngine\Manager;
use OCA\WorkflowEngine\Service\Logger;
use OCP\AppFramework\App;
use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Template;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityCompat;
use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\IOperationCompat;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class Application extends \OCP\AppFramework\App {
class Application extends App {
public const APP_ID = 'workflowengine';

/** @var EventDispatcherInterface */
/** @var IEventDispatcher */
protected $dispatcher;
/** @var Manager */
protected $manager;
Expand All @@ -47,7 +48,7 @@ public function __construct() {

$this->getContainer()->registerAlias('RequestTimeController', RequestTime::class);

$this->dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
$this->dispatcher = $this->getContainer()->getServer()->query(IEventDispatcher::class);
$this->manager = $this->getContainer()->query(Manager::class);
}

Expand Down
22 changes: 9 additions & 13 deletions apps/workflowengine/lib/Settings/ASettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@
use OCA\WorkflowEngine\AppInfo\Application;
use OCA\WorkflowEngine\Manager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\Settings\ISettings;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
use OCP\WorkflowEngine\ICheck;
use OCP\WorkflowEngine\IComplexOperation;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityEvent;
use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\ISpecificOperation;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

abstract class ASettings implements ISettings {
/** @var IL10N */
Expand All @@ -47,7 +48,7 @@ abstract class ASettings implements ISettings {
/** @var string */
private $appName;

/** @var EventDispatcherInterface */
/** @var IEventDispatcher */
private $eventDispatcher;

/** @var Manager */
Expand All @@ -59,18 +60,10 @@ abstract class ASettings implements ISettings {
/** @var IConfig */
private $config;

/**
* @param string $appName
* @param IL10N $l
* @param EventDispatcherInterface $eventDispatcher
* @param Manager $manager
* @param IInitialStateService $initialStateService
* @param IConfig $config
*/
public function __construct(
$appName,
string $appName,
IL10N $l,
EventDispatcherInterface $eventDispatcher,
IEventDispatcher $eventDispatcher,
Manager $manager,
IInitialStateService $initialStateService,
IConfig $config
Expand All @@ -89,7 +82,10 @@ abstract public function getScope(): int;
* @return TemplateResponse
*/
public function getForm() {
$this->eventDispatcher->dispatch('OCP\WorkflowEngine::loadAdditionalSettingScripts');
$this->eventDispatcher->dispatch(
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
new LoadSettingsScriptsEvent()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see here directly typed events. Because then we can properly use the new classes. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me add this.

);

$entities = $this->manager->getEntitiesList();
$this->initialStateService->provideInitialState(
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
'OCP\\WorkflowEngine\\EntityContext\\IUrl' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IUrl.php',
'OCP\\WorkflowEngine\\Events\\LoadSettingsScriptsEvent' => $baseDir . '/lib/public/WorkflowEngine/Events/LoadSettingsScriptsEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterChecksEvent' => $baseDir . '/lib/public/WorkflowEngine/Events/RegisterChecksEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterEntitiesEvent' => $baseDir . '/lib/public/WorkflowEngine/Events/RegisterEntitiesEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterOperationsEvent' => $baseDir . '/lib/public/WorkflowEngine/Events/RegisterOperationsEvent.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
'OCP\\WorkflowEngine\\EntityContext\\IUrl' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IUrl.php',
'OCP\\WorkflowEngine\\Events\\LoadSettingsScriptsEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/Events/LoadSettingsScriptsEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterChecksEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/Events/RegisterChecksEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterEntitiesEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/Events/RegisterEntitiesEvent.php',
'OCP\\WorkflowEngine\\Events\\RegisterOperationsEvent' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/Events/RegisterOperationsEvent.php',
Expand Down
34 changes: 34 additions & 0 deletions lib/public/WorkflowEngine/Events/LoadSettingsScriptsEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @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\Events;

use OCP\EventDispatcher\Event;

/**
* @since 20.0.0
*/
class LoadSettingsScriptsEvent extends Event {
}