-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathTypeSystem.php.skeleton
40 lines (37 loc) · 1.41 KB
/
TypeSystem.php.skeleton
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
29
30
31
32
33
34
35
36
37
38
39
40
<?php
<namespace>
<useStatement>
<classDocBlock>
<classType>class <className> extends <parentClassName><implements>
{<traits>
<spaces>public function __construct(ContainerInterface $container)
<spaces>{
<spaces><spaces>$request = null;
<spaces><spaces>$token = null;
<spaces><spaces>$user = null;
<spaces><spaces>if ($container->has('request_stack')) {
<spaces><spaces><spaces>$request = $container->get('request_stack')->getCurrentRequest();
<spaces><spaces>}
<spaces><spaces>if ($container->has('security.token_storage')) {
<spaces><spaces><spaces>$token = $container->get('security.token_storage')->getToken();
<spaces><spaces><spaces>if ($token instanceof TokenInterface) {
<spaces><spaces><spaces><spaces>$user = $token->getUser();
<spaces><spaces><spaces>}
<spaces><spaces>}
<spaces><spaces>parent::__construct(<config>);
<spaces>}
<spaces>private static function applyPublicFilters($fields)
<spaces>{
<spaces><spaces>$filtered = [];
<spaces><spaces>foreach ($fields as $fieldName => $field) {
<spaces><spaces><spaces>$isPublic = isset($field['public']) ? $field['public'] : true;
<spaces><spaces><spaces>if (is_callable($isPublic)) {
<spaces><spaces><spaces><spaces>$isPublic = call_user_func($isPublic, $fieldName);
<spaces><spaces><spaces>}
<spaces><spaces><spaces>if ($isPublic) {
<spaces><spaces><spaces><spaces>$filtered[$fieldName] = $field;
<spaces><spaces><spaces>}
<spaces><spaces>}
<spaces><spaces>return $filtered;
<spaces>}
}