|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Flextype\Plugin\Admin\Controllers; |
|
6
|
|
|
|
|
7
|
|
|
use DateTime; |
|
8
|
|
|
use Flextype\Component\Arrays\Arrays; |
|
9
|
|
|
use Flextype\Component\Filesystem\Filesystem; |
|
10
|
|
|
use Psr\Http\Message\ResponseInterface as Response; |
|
|
|
|
|
|
11
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request; |
|
|
|
|
|
|
12
|
|
|
use function array_merge; |
|
13
|
|
|
use function explode; |
|
14
|
|
|
use function Flextype\Component\I18n\__; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class SettingsController |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Index page |
|
20
|
|
|
* |
|
21
|
|
|
* @param Request $request PSR7 request |
|
22
|
|
|
* @param Response $response PSR7 response |
|
23
|
|
|
*/ |
|
24
|
|
|
public function index(/** @scrutinizer ignore-unused */ Request $request, Response $response) : Response |
|
25
|
|
|
{ |
|
26
|
|
|
return flextype('twig')->render( |
|
|
|
|
|
|
27
|
|
|
$response, |
|
28
|
|
|
'plugins/admin/templates/system/settings/index.html', |
|
29
|
|
|
[ |
|
30
|
|
|
'data' => Filesystem::read(PATH['project'] . '/config/flextype/settings.yaml'), |
|
|
|
|
|
|
31
|
|
|
'menu_item' => 'settings', |
|
32
|
|
|
'links' => [ |
|
33
|
|
|
'settings' => [ |
|
34
|
|
|
'link' => flextype('router')->pathFor('admin.settings.index'), |
|
35
|
|
|
'title' => __('admin_settings'), |
|
|
|
|
|
|
36
|
|
|
'active' => true |
|
37
|
|
|
], |
|
38
|
|
|
], |
|
39
|
|
|
'buttons' => [ |
|
40
|
|
|
'save' => [ |
|
41
|
|
|
'link' => 'javascript:;', |
|
42
|
|
|
'title' => __('admin_save'), |
|
43
|
|
|
'type' => 'action' |
|
44
|
|
|
], |
|
45
|
|
|
], |
|
46
|
|
|
] |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Update settings process |
|
52
|
|
|
* |
|
53
|
|
|
* @param Request $request PSR7 request |
|
54
|
|
|
* @param Response $response PSR7 response |
|
55
|
|
|
*/ |
|
56
|
|
|
public function updateSettingsProcess(Request $request, Response $response) : Response |
|
57
|
|
|
{ |
|
58
|
|
|
$post_data = $request->getParsedBody(); |
|
59
|
|
|
|
|
60
|
|
|
if (Filesystem::write(PATH['project'] . '/config/flextype/' . '/settings.yaml', $post_data['data'])) { |
|
|
|
|
|
|
61
|
|
|
flextype('flash')->addMessage('success', __('admin_message_settings_saved')); |
|
|
|
|
|
|
62
|
|
|
} else { |
|
63
|
|
|
flextype('flash')->addMessage('error', __('admin_message_settings_was_not_saved')); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $response->withRedirect(flextype('router')->pathFor('admin.settings.index')); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Return date formats allowed |
|
71
|
|
|
* |
|
72
|
|
|
* @return array |
|
73
|
|
|
*/ |
|
74
|
|
|
public function dateFormats() : array |
|
75
|
|
|
{ |
|
76
|
|
|
$now = new DateTime(); |
|
77
|
|
|
|
|
78
|
|
|
return [ |
|
79
|
|
|
'd-m-Y H:i' => $now->format('d-m-Y H:i'), |
|
80
|
|
|
'Y-m-d H:i' => $now->format('Y-m-d H:i'), |
|
81
|
|
|
'm/d/Y h:i a' => $now->format('m/d/Y h:i a'), |
|
82
|
|
|
'H:i d-m-Y' => $now->format('H:i d-m-Y'), |
|
83
|
|
|
'h:i a m/d/Y' => $now->format('h:i a m/d/Y'), |
|
84
|
|
|
]; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Return display date formats allowed |
|
89
|
|
|
* |
|
90
|
|
|
* @return array |
|
91
|
|
|
*/ |
|
92
|
|
|
public function displayDateFormats() : array |
|
93
|
|
|
{ |
|
94
|
|
|
$now = new DateTime(); |
|
95
|
|
|
|
|
96
|
|
|
return [ |
|
97
|
|
|
'F jS \\a\\t g:ia' => $now->format('F jS \\a\\t g:ia'), |
|
98
|
|
|
'l jS \\of F g:i A' => $now->format('l jS \\of F g:i A'), |
|
99
|
|
|
'D, d M Y G:i:s' => $now->format('m/d/Y h:i a'), |
|
100
|
|
|
'd-m-y G:i' => $now->format('d-m-y G:i'), |
|
101
|
|
|
'jS M Y' => $now->format('jS M Y'), |
|
102
|
|
|
]; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths