@@ -24,7 +24,7 @@ |
||
24 | 24 | $config['directory'] ?? $container->getParameter('kernel.project_dir') . '/src/' |
25 | 25 | ); |
26 | 26 | |
27 | - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
27 | + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
28 | 28 | $loader->load('reader.xml'); |
29 | 29 | } |
30 | 30 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $this->annotationReader = $container->get('annotation_reader'); |
47 | 47 | $files = $this->findFiles( |
48 | - $container->getParameter('sonata_annotation.directory') |
|
48 | + $container->getParameter('sonata_annotation.directory') |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | foreach ($files as $file) { |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | if (!($annotation = $this->getClassAnnotation( |
61 | - new ReflectionClass($className) |
|
61 | + new ReflectionClass($className) |
|
62 | 62 | ))) { |
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $definition = new Definition( |
67 | - $annotation->admin, |
|
68 | - [ |
|
67 | + $annotation->admin, |
|
68 | + [ |
|
69 | 69 | new Reference('sonata.annotation.reader.action_button'), |
70 | 70 | new Reference('sonata.annotation.reader.datagrid'), |
71 | 71 | new Reference('sonata.annotation.reader.datagrid_values'), |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | new Reference('sonata.annotation.reader.list'), |
76 | 76 | new Reference('sonata.annotation.reader.route'), |
77 | 77 | new Reference('sonata.annotation.reader.show'), |
78 | - ] |
|
78 | + ] |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | $definition->addTag( |
82 | - 'sonata.admin', |
|
83 | - array_merge( |
|
82 | + 'sonata.admin', |
|
83 | + array_merge( |
|
84 | 84 | $annotation->getTagOptions(), |
85 | 85 | ['model_class' => $className], |
86 | - ) |
|
86 | + ) |
|
87 | 87 | ); |
88 | 88 | |
89 | 89 | $container->setDefinition( |
90 | - $annotation->serviceId ?? $this->getServiceId($file), |
|
91 | - $definition |
|
90 | + $annotation->serviceId ?? $this->getServiceId($file), |
|
91 | + $definition |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | private function findFiles(string $directory): IteratorAggregate |
104 | 104 | { |
105 | 105 | return Finder::create() |
106 | - ->in($directory) |
|
107 | - ->files() |
|
108 | - ->name('*.php'); |
|
106 | + ->in($directory) |
|
107 | + ->files() |
|
108 | + ->name('*.php'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | private function getClassAnnotation(ReflectionClass $class): ?Admin |
167 | 167 | { |
168 | 168 | return $this->annotationReader->getClassAnnotation( |
169 | - $class, |
|
170 | - Admin::class |
|
169 | + $class, |
|
170 | + Admin::class |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | return self::DEFAULT_SERVICE_PREFIX . $this->getClassName( |
184 | 184 | $file->getFilename() |
185 | - ); |
|
185 | + ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $class = $this->getClass($container, $id); |
45 | 45 | |
46 | 46 | if ($permissions = $this->getRoles( |
47 | - new ReflectionClass($class), |
|
48 | - $this->getRolePrefix($id) |
|
47 | + new ReflectionClass($class), |
|
48 | + $this->getRolePrefix($id) |
|
49 | 49 | )) { |
50 | 50 | $roles = array_merge_recursive($roles, $permissions); |
51 | 51 | } |
@@ -87,17 +87,17 @@ discard block |
||
87 | 87 | |
88 | 88 | if (!isset($annotation->role)) { |
89 | 89 | throw new MissingAnnotationArgumentException( |
90 | - $annotation, |
|
91 | - 'role', |
|
92 | - $class |
|
90 | + $annotation, |
|
91 | + 'role', |
|
92 | + $class |
|
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
96 | 96 | $roles[$annotation->role] = array_map( |
97 | - function (string $permission) use ($prefix) { |
|
98 | - return $prefix . strtoupper($permission); |
|
99 | - }, |
|
100 | - $annotation->permissions |
|
97 | + function (string $permission) use ($prefix) { |
|
98 | + return $prefix . strtoupper($permission); |
|
99 | + }, |
|
100 | + $annotation->permissions |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 |
@@ -94,7 +94,7 @@ |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | $roles[$annotation->role] = array_map( |
97 | - function (string $permission) use ($prefix) { |
|
97 | + function(string $permission) use ($prefix) { |
|
98 | 98 | return $prefix . strtoupper($permission); |
99 | 99 | }, |
100 | 100 | $annotation->permissions |
@@ -57,9 +57,9 @@ |
||
57 | 57 | public function getSettings(): array |
58 | 58 | { |
59 | 59 | return [ |
60 | - $this->type ?? null, |
|
61 | - $this->options, |
|
62 | - $this->fieldDescriptionOptions, |
|
60 | + $this->type ?? null, |
|
61 | + $this->options, |
|
62 | + $this->fieldDescriptionOptions, |
|
63 | 63 | ]; |
64 | 64 | } |
65 | 65 |
@@ -47,10 +47,10 @@ |
||
47 | 47 | public function getSettings(): array |
48 | 48 | { |
49 | 49 | return [ |
50 | - $this->type ?? null, |
|
51 | - $this->filterOptions, |
|
52 | - $this->fieldOptions, |
|
53 | - $this->fieldDescriptionOptions, |
|
50 | + $this->type ?? null, |
|
51 | + $this->filterOptions, |
|
52 | + $this->fieldOptions, |
|
53 | + $this->fieldDescriptionOptions, |
|
54 | 54 | ]; |
55 | 55 | } |
56 | 56 |
@@ -129,18 +129,18 @@ |
||
129 | 129 | public function getTagOptions(): array |
130 | 130 | { |
131 | 131 | return [ |
132 | - 'code' => $this->code ?? null, |
|
133 | - 'controller' => $this->controller ?? null, |
|
134 | - 'manager_type' => $this->managerType, |
|
135 | - 'group' => $this->group ?? null, |
|
136 | - 'label' => $this->label ?? null, |
|
137 | - 'show_in_dashboard' => $this->showInDashboard, |
|
138 | - 'keep_open' => $this->keepOpen, |
|
139 | - 'on_top' => $this->onTop, |
|
140 | - 'icon' => $this->icon ?? null, |
|
141 | - 'label_translator_strategy' => $this->labelTranslatorStrategy ?? null, |
|
142 | - 'label_catalogue' => $this->labelCatalogue ?? null, |
|
143 | - 'pager_type' => $this->pagerType ?? null, |
|
132 | + 'code' => $this->code ?? null, |
|
133 | + 'controller' => $this->controller ?? null, |
|
134 | + 'manager_type' => $this->managerType, |
|
135 | + 'group' => $this->group ?? null, |
|
136 | + 'label' => $this->label ?? null, |
|
137 | + 'show_in_dashboard' => $this->showInDashboard, |
|
138 | + 'keep_open' => $this->keepOpen, |
|
139 | + 'on_top' => $this->onTop, |
|
140 | + 'icon' => $this->icon ?? null, |
|
141 | + 'label_translator_strategy' => $this->labelTranslatorStrategy ?? null, |
|
142 | + 'label_catalogue' => $this->labelCatalogue ?? null, |
|
143 | + 'pager_type' => $this->pagerType ?? null, |
|
144 | 144 | ]; |
145 | 145 | } |
146 | 146 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * annotation. |
21 | 21 | */ |
22 | 22 | public function __construct( |
23 | - $annotation, |
|
24 | - string $argumentName, |
|
25 | - $class = null |
|
23 | + $annotation, |
|
24 | + string $argumentName, |
|
25 | + $class = null |
|
26 | 26 | ) { |
27 | 27 | if ($annotation instanceof AnnotationInterface) { |
28 | 28 | $annotation = get_class($annotation); |
@@ -34,31 +34,31 @@ discard block |
||
34 | 34 | |
35 | 35 | if (!is_string($annotation)) { |
36 | 36 | throw new InvalidArgumentException( |
37 | - sprintf( |
|
37 | + sprintf( |
|
38 | 38 | 'Invalid annotation (string|%s) attribute.', |
39 | 39 | AnnotationInterface::class, |
40 | - ) |
|
40 | + ) |
|
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | if ($class !== null && !is_string($class)) { |
45 | 45 | throw new InvalidArgumentException( |
46 | - 'Invalid class (string|ReflectionClass|null) attribute.', |
|
46 | + 'Invalid class (string|ReflectionClass|null) attribute.', |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($class) { |
51 | 51 | $message = sprintf( |
52 | - 'Argument "%s" is mandatory for annotation %s on %s.', |
|
53 | - $argumentName, |
|
54 | - $annotation, |
|
55 | - $class |
|
52 | + 'Argument "%s" is mandatory for annotation %s on %s.', |
|
53 | + $argumentName, |
|
54 | + $annotation, |
|
55 | + $class |
|
56 | 56 | ); |
57 | 57 | } else { |
58 | 58 | $message = sprintf( |
59 | - 'Argument "%s" is mandatory for annotation %s.', |
|
60 | - $argumentName, |
|
61 | - $annotation, |
|
59 | + 'Argument "%s" is mandatory for annotation %s.', |
|
60 | + $argumentName, |
|
61 | + $annotation, |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 |
@@ -38,16 +38,16 @@ |
||
38 | 38 | if ($this->isSupported($annotation)) { |
39 | 39 | if (!isset($annotation->template)) { |
40 | 40 | throw new MissingAnnotationArgumentException( |
41 | - $annotation, |
|
42 | - 'template', |
|
43 | - $class |
|
41 | + $annotation, |
|
42 | + 'template', |
|
43 | + $class |
|
44 | 44 | ); |
45 | 45 | } |
46 | 46 | |
47 | 47 | /** @var AbstractAction $annotation */ |
48 | 48 | $actions[random_int( |
49 | 49 | -99999, |
50 | - 99999 |
|
50 | + 99999 |
|
51 | 51 | )]['template'] = $annotation->template; |
52 | 52 | } |
53 | 53 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * @return void |
36 | 36 | */ |
37 | 37 | public function configureFields( |
38 | - ReflectionClass $class, |
|
39 | - ShowMapper $showMapper |
|
38 | + ReflectionClass $class, |
|
39 | + ShowMapper $showMapper |
|
40 | 40 | ): void { |
41 | 41 | $propertiesAndMethodsWithPosition = []; |
42 | 42 | $propertiesAndMethodsWithoutPosition = []; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | if ($annotation instanceof ShowAssociationField) { |
57 | 57 | if (!isset($annotation->field)) { |
58 | 58 | throw new MissingAnnotationArgumentException( |
59 | - $annotation, |
|
60 | - 'field', |
|
59 | + $annotation, |
|
60 | + 'field', |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | |
@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | |
67 | 67 | if (!isset($annotation->position)) { |
68 | 68 | $propertiesAndMethodsWithoutPosition[] = [ |
69 | - 'name' => $name, |
|
70 | - 'settings' => $annotation->getSettings(), |
|
69 | + 'name' => $name, |
|
70 | + 'settings' => $annotation->getSettings(), |
|
71 | 71 | ]; |
72 | 72 | |
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | |
76 | 76 | if (array_key_exists( |
77 | - $annotation->position, |
|
78 | - $propertiesAndMethodsWithPosition |
|
77 | + $annotation->position, |
|
78 | + $propertiesAndMethodsWithPosition |
|
79 | 79 | )) { |
80 | 80 | throw new InvalidArgumentException( |
81 | - sprintf( |
|
81 | + sprintf( |
|
82 | 82 | 'Position "%s" is already in use by "%s", try setting a different position for "%s".', |
83 | 83 | $annotation->position, |
84 | 84 | $propertiesAndMethodsWithPosition[$annotation->position]['name'], |
85 | 85 | $property->getName() |
86 | - ) |
|
86 | + ) |
|
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
90 | 90 | $propertiesAndMethodsWithPosition[$annotation->position] = [ |
91 | - 'name' => $name, |
|
92 | - 'settings' => $annotation->getSettings(), |
|
91 | + 'name' => $name, |
|
92 | + 'settings' => $annotation->getSettings(), |
|
93 | 93 | ]; |
94 | 94 | } |
95 | 95 | } |
@@ -101,37 +101,37 @@ discard block |
||
101 | 101 | foreach ($class->getMethods() as $method) { |
102 | 102 | /** @var ShowField|null $annotation */ |
103 | 103 | if ($annotation = $this->getMethodAnnotation( |
104 | - $method, |
|
105 | - ShowField::class |
|
104 | + $method, |
|
105 | + ShowField::class |
|
106 | 106 | )) { |
107 | 107 | $name = $method->getName(); |
108 | 108 | |
109 | 109 | if (!isset($annotation->position)) { |
110 | 110 | $propertiesAndMethodsWithoutPosition[] = [ |
111 | - 'name' => $name, |
|
112 | - 'settings' => $annotation->getSettings(), |
|
111 | + 'name' => $name, |
|
112 | + 'settings' => $annotation->getSettings(), |
|
113 | 113 | ]; |
114 | 114 | |
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | 118 | if (array_key_exists( |
119 | - $annotation->position, |
|
120 | - $propertiesAndMethodsWithPosition |
|
119 | + $annotation->position, |
|
120 | + $propertiesAndMethodsWithPosition |
|
121 | 121 | )) { |
122 | 122 | throw new InvalidArgumentException( |
123 | - sprintf( |
|
123 | + sprintf( |
|
124 | 124 | 'Position "%s" is already in use by "%s", try setting a different position for "%s".', |
125 | 125 | $annotation->position, |
126 | 126 | $propertiesAndMethodsWithPosition[$annotation->position]['name'], |
127 | 127 | $name |
128 | - ) |
|
128 | + ) |
|
129 | 129 | ); |
130 | 130 | } |
131 | 131 | |
132 | 132 | $propertiesAndMethodsWithPosition[$annotation->position] = [ |
133 | - 'name' => $name, |
|
134 | - 'settings' => $annotation->getSettings(), |
|
133 | + 'name' => $name, |
|
134 | + 'settings' => $annotation->getSettings(), |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | } |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | ksort($propertiesAndMethodsWithPosition); |
144 | 144 | |
145 | 145 | $propertiesAndMethods = array_merge( |
146 | - $propertiesAndMethodsWithPosition, |
|
147 | - $propertiesAndMethodsWithoutPosition |
|
146 | + $propertiesAndMethodsWithPosition, |
|
147 | + $propertiesAndMethodsWithoutPosition |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | foreach ($propertiesAndMethods as $propertyAndMethod) { |
151 | 151 | $showMapper->add( |
152 | - $propertyAndMethod['name'], |
|
153 | - ... |
|
154 | - $propertyAndMethod['settings'] |
|
152 | + $propertyAndMethod['name'], |
|
153 | + ... |
|
154 | + $propertyAndMethod['settings'] |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |