File tree 6 files changed +59
-16
lines changed
6 files changed +59
-16
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
- ` Fixed ` for any bug fixes.
14
14
- ` Security ` in case of vulnerabilities
15
15
16
+ ## [ 1.5.0] - 2025.03.07
17
+
18
+ ### Added
19
+
20
+ - Added ` getJsonBody ` method to ` WebAppController `
21
+
22
+ ### Changed
23
+
24
+ - Changed array keys of Veil template data in ` setWebAppData `
25
+
16
26
## [ 1.4.0] - 2025.01.10
17
27
18
28
### Added
19
29
20
- Added public ` Translate ` class to ` WebAppService `
30
+ - Added public ` Translate ` class to ` WebAppService `
21
31
22
32
## [ 1.3.0] - 2025.01.19
23
33
Original file line number Diff line number Diff line change 30
30
"bayfrontmedia/bones" : " ^5.3" ,
31
31
"bayfrontmedia/php-array-helpers" : " ^2.0" ,
32
32
"bayfrontmedia/php-cookies" : " ^2.0" ,
33
+ "bayfrontmedia/php-http-request" : " ^3.1" ,
33
34
"bayfrontmedia/route-it" : " ^3.1" ,
34
35
"bayfrontmedia/translation" : " ^2.0" ,
35
36
"bayfrontmedia/veil" : " ^2.1"
Original file line number Diff line number Diff line change @@ -10,8 +10,23 @@ The [WebAppService class](webappservice-class.md) is available within the contro
10
10
11
11
Methods:
12
12
13
+ - [ getJsonBody] ( #getjsonbody )
13
14
- [ respond] ( #respond )
14
15
16
+ ## getJsonBody
17
+
18
+ ** Description:**
19
+
20
+ Get JSON body from request as array, or return empty array if not existing.
21
+
22
+ ** Parameters:**
23
+
24
+ - (none)
25
+
26
+ ** Returns:**
27
+
28
+ - (array)
29
+
15
30
## respond
16
31
17
32
** Description:**
Original file line number Diff line number Diff line change @@ -64,10 +64,9 @@ Add support for the `@say:` template tag which returns the translation of a give
64
64
65
65
Set web app data for use in Veil templates.
66
66
67
- - ` app.version ` : As defined at ` app.version ` config array, if existing
68
- - ` locale.current `
69
- - ` locale.valid `
70
- - ` webapp ` : ` webapp.public ` config array
67
+ - ` webapp.locale.current `
68
+ - ` webapp.locale.valid `
69
+ - ` webapp.public ` : ` webapp.public ` config array
71
70
72
71
** Parameters:**
73
72
Original file line number Diff line number Diff line change 6
6
use Bayfront \BonesService \WebApp \Exceptions \WebAppServiceException ;
7
7
use Bayfront \BonesService \WebApp \Interfaces \WebAppControllerInterface ;
8
8
use Bayfront \BonesService \WebApp \WebAppService ;
9
+ use Bayfront \HttpRequest \Request ;
9
10
use Bayfront \HttpResponse \InvalidStatusCodeException ;
10
11
use Bayfront \Veil \FileNotFoundException ;
11
12
@@ -31,6 +32,24 @@ public function __construct(WebAppService $webAppService)
31
32
32
33
}
33
34
35
+ /**
36
+ * Get JSON body from request as array, or return empty array if not existing.
37
+ *
38
+ * @return array
39
+ */
40
+ public function getJsonBody (): array
41
+ {
42
+
43
+ $ body = json_decode (Request::getBody (), true );
44
+
45
+ if (!$ body || !is_array ($ body )) {
46
+ return [];
47
+ }
48
+
49
+ return $ body ;
50
+
51
+ }
52
+
34
53
/**
35
54
* Send web app response.
36
55
*
Original file line number Diff line number Diff line change @@ -151,26 +151,25 @@ public function addTagSay(string $body): string
151
151
/**
152
152
* Set web app data for use in Veil templates.
153
153
*
154
- * - app.version (As defined at app.version config array, if existing)
155
- * - locale.current
156
- * - locale.valid
157
- * - webapp (webapp.public config array)
154
+ * - webapp.locale.current
155
+ * - webapp.locale.valid
156
+ * - webapp.public (webapp.public config array)
158
157
*
159
158
* @param array $data
160
159
* @return array
161
160
*/
162
161
public function setWebAppData (array $ data ): array
163
162
{
164
163
$ data = array_merge ($ data , [
165
- 'locale ' => [
166
- 'current ' => $ this ->translate ->getLocale (),
167
- 'valid ' => App::getConfig ('webapp.locale.valid ' , [])
168
- ],
169
- 'webapp ' => App::getConfig ('webapp.public ' , [])
164
+ 'webapp ' => [
165
+ 'locale ' => [
166
+ 'current ' => $ this ->translate ->getLocale (),
167
+ 'valid ' => App::getConfig ('webapp.locale.valid ' , [])
168
+ ],
169
+ 'public ' => App::getConfig ('webapp.public ' , [])
170
+ ]
170
171
]);
171
172
172
- $ data ['app ' ]['version ' ] = App::getConfig ('app.version ' );
173
-
174
173
VeilData::set ($ data );
175
174
return $ data ;
176
175
}
You can’t perform that action at this time.
0 commit comments