-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBaseAccessFunction.php
More file actions
28 lines (24 loc) · 863 Bytes
/
BaseAccessFunction.php
File metadata and controls
28 lines (24 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace BD\EzPlatformGraphQLBundle\GraphQL\ExpressionLanguage\Access;
use Overblog\GraphQLBundle\ExpressionLanguage\ExpressionFunction;
abstract class BaseAccessFunction extends ExpressionFunction
{
protected function buildHasAccessCode(array $policies)
{
$checks = array_map(
function($policy) {
list($module, $function) = explode('/', $policy);
return sprintf(
'(true === ($access = $pr->hasAccess("%s", "%s")) || is_array($access))',
$module,
$function
);
},
$policies
);
return sprintf('(function() use ($globalVariable) {
$pr = $globalVariable->get("container")->get("eZ\Publish\API\Repository\PermissionResolver");
return %s;
})()', implode('||', $checks));
}
}