1
0
mirror of https://github.com/flarum/core.git synced 2025-10-15 08:55:53 +02:00

Fix Callables for Extenders (#2423)

- Standardize signatures and variable names for extenders that take callbacks
- Adjust model extender docblock to clarify that default calue can't be an invokable class.
- Make invokable classes provided to Model->relationship
- Add integration tests to ensure Model->relationship and User->groupProcessor extenders accept callbacks
- Extract code for wrapping callbacks into central util
This commit is contained in:
Alexander Skvortsov
2020-11-08 21:36:38 -05:00
committed by GitHub
parent c10cc92deb
commit 47d2eee9ce
10 changed files with 108 additions and 39 deletions

View File

@@ -35,7 +35,7 @@ class User implements ExtenderInterface
* This can be used to give a user permissions for groups they aren't actually in, based on context.
* It will not change the group badges displayed for the user.
*
* @param callable $callable
* @param callable|string $callback
*
* The callable can be a closure or invokable class, and should accept:
* - \Flarum\User\User $user: the user in question.
@@ -44,9 +44,9 @@ class User implements ExtenderInterface
* The callable should return:
* - array $groupIds: an array of ids for the groups the user belongs to.
*/
public function permissionGroups(callable $callable)
public function permissionGroups($callback)
{
$this->groupProcessors[] = $callable;
$this->groupProcessors[] = $callback;
return $this;
}