Added support for task:action (like task but works without nonce)

This commit is contained in:
Matias Griese
2018-11-30 23:04:34 +02:00
parent cd5bda3f9e
commit 8fdd34c245
3 changed files with 15 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
* Added `orderBy()` and `limit()` methods to `ObjectCollectionInterface` and its base classes
* Flex: Added support for custom object index classes (API compatibility break)
* Added `user-data://` which is a writable stream (`user://data` is not and should be avoided)
* Added support for `task:action` (like task but works without nonce)
1. [](#improved)
* Improve Flex storage
1. [](#bugfix)

View File

@@ -24,7 +24,8 @@ class TasksProcessor extends ProcessorBase
$this->startTimer();
$task = $this->container['task'];
if ($task) {
$action = $this->container['action'];
if ($task || $action) {
$attributes = $request->getAttribute('controller');
$controllerClass = $attributes['class'] ?? null;
@@ -38,7 +39,9 @@ class TasksProcessor extends ProcessorBase
}
}
$this->container->fireEvent('onTask.' . $task);
if ($task) {
$this->container->fireEvent('onTask.' . $task);
}
}
$this->stopTimer();

View File

@@ -24,5 +24,14 @@ class TaskServiceProvider implements ServiceProviderInterface
return $task ?: null;
};
$container['action'] = function (Grav $c) {
$action = $_POST['action'] ?? $c['uri']->param('action');
if (null !== $action) {
$action = filter_var($action, FILTER_SANITIZE_STRING);
}
return $action ?: null;
};
}
}