Skip to content

Commit 1b9f9a7

Browse files
committed
Remove php side of check registration
1 parent fc6bf0b commit 1b9f9a7

File tree

5 files changed

+9
-118
lines changed

5 files changed

+9
-118
lines changed

apps/workflowengine/appinfo/routes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
return [
2323
'routes' => [
24-
['name' => 'flowOperations#getChecks', 'url' => '/checks', 'verb' => 'GET'], // TODO rm and do via js?
2524
['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'],
2625
['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
2726
['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],

apps/workflowengine/lib/AppInfo/Application.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ public function __construct() {
3737
*/
3838
public function registerHooksAndListeners() {
3939
$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
40-
$dispatcher->addListener(
41-
'OCP\WorkflowEngine\RegisterCheckEvent',
42-
function(RegisterCheckEvent $event) {
43-
$event->addCheck(
44-
'OCA\WorkflowEngine\Check\UserGroupMembership',
45-
'User group membership',
46-
['is', '!is']
47-
);
48-
},
49-
-100
50-
);
51-
5240
$dispatcher->addListener(
5341
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
5442
function() {

apps/workflowengine/lib/Controller/FlowOperations.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,19 @@
2626
use OCP\AppFramework\Http;
2727
use OCP\AppFramework\Http\JSONResponse;
2828
use OCP\IRequest;
29-
use OCP\WorkflowEngine\RegisterCheckEvent;
30-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
3129

3230
class FlowOperations extends Controller {
3331

3432
/** @var Manager */
3533
protected $manager;
3634

37-
/** @var EventDispatcherInterface */
38-
protected $dispatcher;
39-
4035
/**
4136
* @param IRequest $request
4237
* @param Manager $manager
43-
* @param EventDispatcherInterface $dispatcher
4438
*/
45-
public function __construct(IRequest $request, Manager $manager, EventDispatcherInterface $dispatcher) {
39+
public function __construct(IRequest $request, Manager $manager) {
4640
parent::__construct('workflowengine', $request);
4741
$this->manager = $manager;
48-
$this->dispatcher = $dispatcher;
49-
}
50-
51-
/**
52-
* @NoCSRFRequired
53-
*
54-
* @return JSONResponse
55-
*/
56-
public function getChecks() {
57-
$event = new RegisterCheckEvent();
58-
$this->dispatcher->dispatch('OCP\WorkflowEngine\RegisterCheckEvent', $event);
59-
60-
return new JSONResponse($event->getChecks());
6142
}
6243

6344
/**

apps/workflowengine/lib/Manager.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ protected function check(array $check) {
110110
$checkInstance->setFileInfo($this->storage, $this->path);
111111
return $checkInstance->executeCheck($check['operator'], $check['value']);
112112
} else {
113-
// Check is invalid, assume it matches.
114-
return true;
113+
// Check is invalid
114+
throw new \RuntimeException('Check ' . htmlspecialchars($check['class']) . ' is invalid or does not exist');
115115
}
116116
}
117117

@@ -258,10 +258,12 @@ public function getChecks(array $checkIds) {
258258
}
259259
$result->closeCursor();
260260

261-
// TODO What if a check is missing? Should we throw?
262-
// As long as we only allow AND-concatenation of checks, a missing check
263-
// is like a matching check, so it evaluates to true and therefor blocks
264-
// access. So better save than sorry.
261+
$checkIds = array_diff($checkIds, array_keys($checks));
262+
263+
if (!empty($checkIds)) {
264+
$missingCheck = array_pop($checkIds);
265+
throw new \RuntimeException('Check #' . htmlspecialchars($missingCheck) . ' is invalid or does not exist');
266+
}
265267

266268
return $checks;
267269
}

lib/public/WorkflowEngine/RegisterCheckEvent.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)