File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 142
142
</head >
143
143
144
144
<body >
145
- <script id =" api-reference" data-url =" {{ config ( ' scalar. url' ) } }" ></script >
145
+ <script id =" api-reference" data-url =" {{ Scalar :: url ( ) } }" ></script >
146
146
147
147
<!-- Optional: You can set a full configuration object like this: -->
148
148
<script >
149
- var configuration = {!! json_encode (
150
- array_merge (config (' scalar.configuration' ), [
151
- ' theme' => config (' scalar.configuration.theme' ) === ' laravel' ? ' none' : config (' scalar.configuration.theme' ),
152
- ]),
153
- ) ! !}
149
+ var configuration = {!! Scalar:: configurationJson () ! !}
154
150
155
151
document .getElementById (' api-reference' ).dataset .configuration =
156
152
JSON .stringify (configuration)
Original file line number Diff line number Diff line change 2
2
3
3
namespace Scalar \Scalar ;
4
4
5
- class Scalar {}
5
+ class Scalar
6
+ {
7
+ public static function url ()
8
+ {
9
+ return config ('scalar.url ' );
10
+ }
11
+
12
+ public static function configurationJson ()
13
+ {
14
+ /** Get the Scalar API Reference configuration */
15
+ $ configuration = config ('scalar.configuration ' );
16
+
17
+ /** Don’t add a theme if `laravel` is selected */
18
+ $ theme = config ('scalar.configuration.theme ' ) === 'laravel ' ?
19
+ 'none ' :
20
+ config ('scalar.configuration.theme ' );
21
+
22
+ /** Render as JSON */
23
+ return json_encode (
24
+ array_merge ($ configuration , [
25
+ 'theme ' => $ theme ,
26
+ ]),
27
+ );
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments