@@ -647,7 +647,7 @@ |
||
647 | 647 | } |
648 | 648 | |
649 | 649 | return ($action === 'encrypt') ? base64_encode($return) : $return; |
650 | - // On renvoie la chaine encrypter ou decrypter |
|
650 | + // On renvoie la chaine encrypter ou decrypter |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -799,9 +799,9 @@ |
||
799 | 799 | return $returned; |
800 | 800 | } |
801 | 801 | |
802 | - if ($returned instanceof Responsable) { |
|
803 | - return $returned->toResponse($this->request); |
|
804 | - } |
|
802 | + if ($returned instanceof Responsable) { |
|
803 | + return $returned->toResponse($this->request); |
|
804 | + } |
|
805 | 805 | |
806 | 806 | if (is_object($returned)) { |
807 | 807 | if (method_exists($returned, '__toString')) { |
@@ -82,9 +82,9 @@ |
||
82 | 82 | */ |
83 | 83 | public function setMethods(?array $methods): self |
84 | 84 | { |
85 | - if (is_array($methods)) { |
|
86 | - $this->methods = $methods; |
|
87 | - } |
|
85 | + if (is_array($methods)) { |
|
86 | + $this->methods = $methods; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | return $this; |
90 | 90 | } |
@@ -754,51 +754,51 @@ discard block |
||
754 | 754 | |
755 | 755 | if (in_array('index', $methods, true)) { |
756 | 756 | $this->get($name, $newName . '::index', $options + [ |
757 | - 'as' => $name . '.index', |
|
758 | - ]); |
|
757 | + 'as' => $name . '.index', |
|
758 | + ]); |
|
759 | 759 | } |
760 | 760 | if (in_array('new', $methods, true)) { |
761 | 761 | $this->get($name . '/new', $newName . '::new', $options + [ |
762 | - 'as' => $name . '.new', |
|
763 | - ]); |
|
762 | + 'as' => $name . '.new', |
|
763 | + ]); |
|
764 | 764 | } |
765 | 765 | if (in_array('edit', $methods, true)) { |
766 | 766 | $this->get($name . '/' . $id . '/edit', $newName . '::edit/$1', $options + [ |
767 | - 'as' => $name . '.edit', |
|
768 | - ]); |
|
767 | + 'as' => $name . '.edit', |
|
768 | + ]); |
|
769 | 769 | } |
770 | 770 | if (in_array('show', $methods, true)) { |
771 | 771 | $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
772 | - 'as' => $name . '.show', |
|
773 | - ]); |
|
772 | + 'as' => $name . '.show', |
|
773 | + ]); |
|
774 | 774 | } |
775 | 775 | if (in_array('create', $methods, true)) { |
776 | 776 | $this->post($name, $newName . '::create', $options + [ |
777 | - 'as' => $name . '.create', |
|
778 | - ]); |
|
777 | + 'as' => $name . '.create', |
|
778 | + ]); |
|
779 | 779 | } |
780 | 780 | if (in_array('update', $methods, true)) { |
781 | - $this->match(['put', 'patch'], $name . '/' . $id, $newName . '::update/$1', $options + [ |
|
782 | - 'as' => $name . '.update', |
|
783 | - ]); |
|
781 | + $this->match(['put', 'patch'], $name . '/' . $id, $newName . '::update/$1', $options + [ |
|
782 | + 'as' => $name . '.update', |
|
783 | + ]); |
|
784 | 784 | } |
785 | 785 | if (in_array('delete', $methods, true)) { |
786 | 786 | $this->delete($name . '/' . $id, $newName . '::delete/$1', $options + [ |
787 | - 'as' => $name . '.delete', |
|
788 | - ]); |
|
787 | + 'as' => $name . '.delete', |
|
788 | + ]); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | // Websafe ? la suppression doit être vérifiée avant la mise à jour en raison du nom de la méthode |
792 | 792 | if (isset($options['websafe'])) { |
793 | 793 | if (in_array('delete', $methods, true)) { |
794 | 794 | $this->post($name . '/' . $id . '/delete', $newName . '::delete/$1', $options + [ |
795 | - 'as' => $name . '.websafe.delete', |
|
796 | - ]); |
|
795 | + 'as' => $name . '.websafe.delete', |
|
796 | + ]); |
|
797 | 797 | } |
798 | 798 | if (in_array('update', $methods, true)) { |
799 | 799 | $this->post($name . '/' . $id, $newName . '::update/$1', $options + [ |
800 | - 'as' => $name . '.websafe.update', |
|
801 | - ]); |
|
800 | + 'as' => $name . '.websafe.update', |
|
801 | + ]); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
@@ -865,49 +865,49 @@ discard block |
||
865 | 865 | |
866 | 866 | if (in_array('index', $methods, true)) { |
867 | 867 | $this->get($name, $newName . '::index', $options + [ |
868 | - 'as' => $name . '.index', |
|
869 | - ]); |
|
868 | + 'as' => $name . '.index', |
|
869 | + ]); |
|
870 | 870 | } |
871 | 871 | if (in_array('show', $methods, true)) { |
872 | 872 | $this->get($name . '/show/' . $id, $newName . '::show/$1', $options + [ |
873 | - 'as' => $name . '.view' |
|
874 | - ]); |
|
875 | - $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
|
876 | - 'as' => $name . '.show' |
|
877 | - ]); |
|
873 | + 'as' => $name . '.view' |
|
874 | + ]); |
|
875 | + $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
|
876 | + 'as' => $name . '.show' |
|
877 | + ]); |
|
878 | 878 | } |
879 | 879 | if (in_array('new', $methods, true)) { |
880 | 880 | $this->get($name . '/new', $newName . '::new', $options + [ |
881 | - 'as' => $name . '.new' |
|
882 | - ]); |
|
881 | + 'as' => $name . '.new' |
|
882 | + ]); |
|
883 | 883 | } |
884 | 884 | if (in_array('create', $methods, true)) { |
885 | 885 | $this->post($name . '/create', $newName . '::create', $options + [ |
886 | - 'as' => $name . '.create' |
|
887 | - ]); |
|
888 | - $this->post($name, $newName . '::create', $options + [ |
|
889 | - 'as' => $name . '.store' |
|
890 | - ]); |
|
886 | + 'as' => $name . '.create' |
|
887 | + ]); |
|
888 | + $this->post($name, $newName . '::create', $options + [ |
|
889 | + 'as' => $name . '.store' |
|
890 | + ]); |
|
891 | 891 | } |
892 | 892 | if (in_array('edit', $methods, true)) { |
893 | 893 | $this->get($name . '/edit/' . $id, $newName . '::edit/$1', $options + [ |
894 | - 'as' => $name . '.edit' |
|
895 | - ]); |
|
894 | + 'as' => $name . '.edit' |
|
895 | + ]); |
|
896 | 896 | } |
897 | 897 | if (in_array('update', $methods, true)) { |
898 | 898 | $this->post($name . '/update/' . $id, $newName . '::update/$1', $options + [ |
899 | - 'as' => $name . '.update', |
|
900 | - ]); |
|
899 | + 'as' => $name . '.update', |
|
900 | + ]); |
|
901 | 901 | } |
902 | 902 | if (in_array('remove', $methods, true)) { |
903 | 903 | $this->get($name . '/remove/' . $id, $newName . '::remove/$1', $options + [ |
904 | - 'as' => $name . '.remove', |
|
905 | - ]); |
|
904 | + 'as' => $name . '.remove', |
|
905 | + ]); |
|
906 | 906 | } |
907 | 907 | if (in_array('delete', $methods, true)) { |
908 | 908 | $this->post($name . '/delete/' . $id, $newName . '::delete/$1', $options + [ |
909 | - 'as' => $name . '.delete', |
|
910 | - ]); |
|
909 | + 'as' => $name . '.delete', |
|
910 | + ]); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | return $this; |
@@ -1424,15 +1424,15 @@ discard block |
||
1424 | 1424 | return array_shift($host); |
1425 | 1425 | } |
1426 | 1426 | |
1427 | - /** |
|
1428 | - * Formate le nom des routes |
|
1429 | - */ |
|
1430 | - private function formatRouteName(string $name): string |
|
1431 | - { |
|
1432 | - $name = trim($name, '/'); |
|
1427 | + /** |
|
1428 | + * Formate le nom des routes |
|
1429 | + */ |
|
1430 | + private function formatRouteName(string $name): string |
|
1431 | + { |
|
1432 | + $name = trim($name, '/'); |
|
1433 | 1433 | |
1434 | - return strtolower(str_replace(['/', '\\', '_', '.', ' '], '.', $name)); |
|
1435 | - } |
|
1434 | + return strtolower(str_replace(['/', '\\', '_', '.', ' '], '.', $name)); |
|
1435 | + } |
|
1436 | 1436 | |
1437 | 1437 | private function getControllerName(Closure|string $handler): ?string |
1438 | 1438 | { |
@@ -25,49 +25,49 @@ discard block |
||
25 | 25 | */ |
26 | 26 | private static array $loaded = []; |
27 | 27 | |
28 | - /** |
|
29 | - * Drapeau permettant de savoir si la config a deja ete initialiser |
|
30 | - */ |
|
31 | - private static bool $initialized = false; |
|
28 | + /** |
|
29 | + * Drapeau permettant de savoir si la config a deja ete initialiser |
|
30 | + */ |
|
31 | + private static bool $initialized = false; |
|
32 | 32 | |
33 | - private Configurator $configurator; |
|
33 | + private Configurator $configurator; |
|
34 | 34 | |
35 | 35 | public function __construct() |
36 | 36 | { |
37 | - $this->configurator = new Configurator(); |
|
38 | - $this->initialize(); |
|
37 | + $this->configurator = new Configurator(); |
|
38 | + $this->initialize(); |
|
39 | 39 | } |
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * Détermine si une clé de configuration existe. |
43 | 43 | */ |
44 | - public function exists(string $key): bool |
|
45 | - { |
|
46 | - if (! $this->configurator->exists($key)) { |
|
47 | - $config = explode('.', $key); |
|
48 | - $this->load($config[0]); |
|
44 | + public function exists(string $key): bool |
|
45 | + { |
|
46 | + if (! $this->configurator->exists($key)) { |
|
47 | + $config = explode('.', $key); |
|
48 | + $this->load($config[0]); |
|
49 | 49 | |
50 | - return $this->configurator->exists(implode('.', $config)); |
|
51 | - } |
|
50 | + return $this->configurator->exists(implode('.', $config)); |
|
51 | + } |
|
52 | 52 | |
53 | - return true; |
|
54 | - } |
|
53 | + return true; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
56 | + /** |
|
57 | 57 | * Détermine s'il y'a une clé de configuration. |
58 | 58 | */ |
59 | - public function has(string $key): bool |
|
60 | - { |
|
61 | - return $this->exists($key); |
|
62 | - } |
|
59 | + public function has(string $key): bool |
|
60 | + { |
|
61 | + return $this->exists($key); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
64 | + /** |
|
65 | 65 | * Détermine s'il manque une clé de configuration. |
66 | 66 | */ |
67 | - public function missing(string $key): bool |
|
68 | - { |
|
69 | - return ! $this->exists($key); |
|
70 | - } |
|
67 | + public function missing(string $key): bool |
|
68 | + { |
|
69 | + return ! $this->exists($key); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Renvoyer une configuration de l'application |
@@ -80,21 +80,21 @@ discard block |
||
80 | 80 | return $this->configurator->get($key); |
81 | 81 | } |
82 | 82 | |
83 | - if (func_num_args() > 1) { |
|
84 | - return $default; |
|
85 | - } |
|
83 | + if (func_num_args() > 1) { |
|
84 | + return $default; |
|
85 | + } |
|
86 | 86 | |
87 | - $path = explode('.', $key); |
|
87 | + $path = explode('.', $key); |
|
88 | 88 | |
89 | - throw ConfigException::notFound(implode(' » ', $path)); |
|
90 | - } |
|
89 | + throw ConfigException::notFound(implode(' » ', $path)); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Définir une configuration de l'application |
94 | 94 | */ |
95 | 95 | public function set(string $key, $value) |
96 | 96 | { |
97 | - $this->configurator->set($key, $value); |
|
97 | + $this->configurator->set($key, $value); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | $schema = self::schema($config); |
133 | 133 | } |
134 | 134 | |
135 | - $this->configurator->addSchema($config, $schema, false); |
|
136 | - $this->configurator->merge([$config => (array) $configurations]); |
|
135 | + $this->configurator->addSchema($config, $schema, false); |
|
136 | + $this->configurator->merge([$config => (array) $configurations]); |
|
137 | 137 | |
138 | 138 | self::$loaded[$config] = $file; |
139 | 139 | } |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | { |
164 | 164 | $path = preg_replace('#\.php$#', '', $path); |
165 | 165 | |
166 | - if (file_exists($file = CONFIG_PATH . $path . '.php')) { |
|
167 | - return $file; |
|
168 | - } |
|
166 | + if (file_exists($file = CONFIG_PATH . $path . '.php')) { |
|
167 | + return $file; |
|
168 | + } |
|
169 | 169 | |
170 | - $paths = Services::locator()->search('Config/' . $path); |
|
170 | + $paths = Services::locator()->search('Config/' . $path); |
|
171 | 171 | |
172 | - if (isset($paths[0]) && file_exists($path[0])) { |
|
173 | - return $paths[0]; |
|
174 | - } |
|
172 | + if (isset($paths[0]) && file_exists($path[0])) { |
|
173 | + return $paths[0]; |
|
174 | + } |
|
175 | 175 | |
176 | - return ''; |
|
176 | + return ''; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | */ |
204 | 204 | private function initialize() |
205 | 205 | { |
206 | - if (self::$initialized) { |
|
207 | - return; |
|
208 | - } |
|
206 | + if (self::$initialized) { |
|
207 | + return; |
|
208 | + } |
|
209 | 209 | |
210 | - $this->load(['app']); |
|
210 | + $this->load(['app']); |
|
211 | 211 | |
212 | 212 | ini_set('log_errors', 1); |
213 | 213 | ini_set('error_log', LOG_PATH . 'blitz-logs'); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $this->initializeEnvironment(); |
217 | 217 | $this->initializeDebugbar(); |
218 | 218 | |
219 | - self::$initialized = true; |
|
219 | + self::$initialized = true; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -115,18 +115,18 @@ |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | if (! function_exists('config')) { |
118 | - /** |
|
118 | + /** |
|
119 | 119 | * GET/SET App config |
120 | 120 | * |
121 | 121 | * @return Config|mixed|void |
122 | 122 | */ |
123 | 123 | function config(array|string|null $key = null, $default = null) |
124 | 124 | { |
125 | - $config = Services::config(); |
|
125 | + $config = Services::config(); |
|
126 | 126 | |
127 | - if (null === $key) { |
|
128 | - return $config; |
|
129 | - } |
|
127 | + if (null === $key) { |
|
128 | + return $config; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | if (is_string($key)) { |
132 | 132 | return $config->get($key, $default); |
@@ -125,17 +125,17 @@ |
||
125 | 125 | return static::$instances[Cache::class] = static::factory(Cache::class, compact('config')); |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * La clase Config offre une api fluide por gerer les configurations de l'application |
|
130 | - */ |
|
131 | - public static function config(bool $shared = true): Config |
|
132 | - { |
|
133 | - if (true === $shared && isset(static::$instances[Config::class])) { |
|
128 | + /** |
|
129 | + * La clase Config offre une api fluide por gerer les configurations de l'application |
|
130 | + */ |
|
131 | + public static function config(bool $shared = true): Config |
|
132 | + { |
|
133 | + if (true === $shared && isset(static::$instances[Config::class])) { |
|
134 | 134 | return static::$instances[Config::class]; |
135 | 135 | } |
136 | 136 | |
137 | - return static::$instances[Config::class] = new Config(); |
|
138 | - } |
|
137 | + return static::$instances[Config::class] = new Config(); |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Émetteur de réponse au client |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
108 | + /** |
|
109 | 109 | * Charge un fichier d'aide en mémoire. |
110 | 110 | * Prend en charge les helpers d'espace de noms, à la fois dans et hors du répertoire 'helpers' d'un répertoire d'espace de noms. |
111 | 111 | */ |
@@ -115,53 +115,53 @@ discard block |
||
115 | 115 | |
116 | 116 | $loader = Services::locator(); |
117 | 117 | |
118 | - // Stockez nos versions de schame système et d'application afin que nous puissions contrôler l'ordre de chargement. |
|
119 | - $systemSchema = null; |
|
120 | - $appSchema = null; |
|
121 | - $vendorSchema = null; |
|
118 | + // Stockez nos versions de schame système et d'application afin que nous puissions contrôler l'ordre de chargement. |
|
119 | + $systemSchema = null; |
|
120 | + $appSchema = null; |
|
121 | + $vendorSchema = null; |
|
122 | 122 | |
123 | - // Le fichier de schema qui sera finalement utiliser |
|
124 | - $file = null; |
|
123 | + // Le fichier de schema qui sera finalement utiliser |
|
124 | + $file = null; |
|
125 | 125 | |
126 | - // Vérifiez si ce schama a déjà été chargé |
|
127 | - if (in_array($name, $loadedSchema, true)) { |
|
126 | + // Vérifiez si ce schama a déjà été chargé |
|
127 | + if (in_array($name, $loadedSchema, true)) { |
|
128 | 128 | return $loadedSchema[$name]; |
129 | - } |
|
130 | - |
|
131 | - // Si le fichier est dans un espace de noms, nous allons simplement saisir ce fichier et ne pas en rechercher d'autres |
|
132 | - if (strpos($name, '\\') !== false) { |
|
133 | - if (!empty($path = $loader->locateFile($name, 'schemas'))) { |
|
134 | - $file = $path; |
|
135 | - } |
|
136 | - } else { |
|
137 | - // Pas d'espaces de noms, donc recherchez dans tous les emplacements disponibles |
|
138 | - $paths = $loader->search('schemas/' . $name); |
|
139 | - |
|
140 | - foreach ($paths as $path) { |
|
141 | - if (strpos($path, CONFIG_PATH . 'schemas' . DS) === 0) { |
|
142 | - $appSchema = $path; |
|
143 | - } elseif (strpos($path, SYST_PATH . 'Constants' . DS . 'schemas' . DS) === 0) { |
|
144 | - $systemSchema = $path; |
|
145 | - } else { |
|
146 | - $vendorSchema = $path; |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - // Les schema des vendor sont prioritaire, ensuite vienne ceux de l'application |
|
151 | - if (!empty($vendorSchema)) { |
|
152 | - $file = $vendorSchema; |
|
153 | - } else if (!empty($appSchema)) { |
|
154 | - $file = $appSchema; |
|
155 | - } else if (!empty($systemSchema)) { |
|
156 | - $file = $systemSchema; |
|
157 | - } |
|
158 | 129 | } |
159 | 130 | |
160 | - if (!empty($file)) { |
|
161 | - $schema = require($file); |
|
162 | - } else { |
|
163 | - $schema = null; |
|
164 | - } |
|
131 | + // Si le fichier est dans un espace de noms, nous allons simplement saisir ce fichier et ne pas en rechercher d'autres |
|
132 | + if (strpos($name, '\\') !== false) { |
|
133 | + if (!empty($path = $loader->locateFile($name, 'schemas'))) { |
|
134 | + $file = $path; |
|
135 | + } |
|
136 | + } else { |
|
137 | + // Pas d'espaces de noms, donc recherchez dans tous les emplacements disponibles |
|
138 | + $paths = $loader->search('schemas/' . $name); |
|
139 | + |
|
140 | + foreach ($paths as $path) { |
|
141 | + if (strpos($path, CONFIG_PATH . 'schemas' . DS) === 0) { |
|
142 | + $appSchema = $path; |
|
143 | + } elseif (strpos($path, SYST_PATH . 'Constants' . DS . 'schemas' . DS) === 0) { |
|
144 | + $systemSchema = $path; |
|
145 | + } else { |
|
146 | + $vendorSchema = $path; |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + // Les schema des vendor sont prioritaire, ensuite vienne ceux de l'application |
|
151 | + if (!empty($vendorSchema)) { |
|
152 | + $file = $vendorSchema; |
|
153 | + } else if (!empty($appSchema)) { |
|
154 | + $file = $appSchema; |
|
155 | + } else if (!empty($systemSchema)) { |
|
156 | + $file = $systemSchema; |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + if (!empty($file)) { |
|
161 | + $schema = require($file); |
|
162 | + } else { |
|
163 | + $schema = null; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | if (empty($schema) || ! ($schema instanceof Schema)) { |
167 | 167 | $schema = Expect::mixed(); |
@@ -159,10 +159,10 @@ |
||
159 | 159 | */ |
160 | 160 | private array $_options = []; |
161 | 161 | |
162 | - /** |
|
163 | - * @param Console $app Application Console |
|
164 | - * @param LoggerInterface $logger Le Logger à utiliser |
|
165 | - */ |
|
162 | + /** |
|
163 | + * @param Console $app Application Console |
|
164 | + * @param LoggerInterface $logger Le Logger à utiliser |
|
165 | + */ |
|
166 | 166 | public function __construct(protected Console $app, protected LoggerInterface $logger) |
167 | 167 | { |
168 | 168 | $this->initProps(); |