mirror of
https://gitlab.com/izyim/prototypes/ddd-example.git
synced 2026-08-21 13:34:19 +00:00
1. authorization helper
2. change unit test to run on memory
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/** */
|
||||
|
||||
use Src\Common\Domain\Exceptions\UnauthorizedUserException;
|
||||
|
||||
if (! function_exists('authorize')) {
|
||||
/* @throws UnauthorizedUserException */
|
||||
function authorize($ability, $policy, $arguments = []): bool
|
||||
{
|
||||
if ($policy->{$ability}(...$arguments)) {
|
||||
return true;
|
||||
}
|
||||
throw new UnauthorizedUserException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user