-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependencies.php
98 lines (83 loc) · 3.12 KB
/
dependencies.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
declare(strict_types=1);
/**
* @link https://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype\Plugin\Form;
use Flextype\Plugin\Form\Models\Fieldsets;
use Flextype\Plugin\Form\Models\Form;
use Flextype\Plugin\Form\Twig\FormTwigExtension;
use Flextype\Plugin\Twig\Twig\FlextypeTwig;
use function array_merge;
use function strtolower;
use function substr;
/**
* Add Form Model to Flextype container
*/
flextype()->container()['form'] = fn() => new Form();
/**
* Add Fieldsets Model to Flextype container
*/
flextype()->container()['fieldsets'] = fn() => new Fieldsets();
/**
* Add Form Twig extension
*/
FlextypeTwig::macro('form', fn() => flextype('form'));
/**
* Add Assets
*/
$adminCSS = flextype('registry')->has('assets.admin.css') ? flextype('registry')->get('assets.admin.css') : [];
$siteCSS = flextype('registry')->has('assets.site.css') ? flextype('registry')->get('assets.site.css') : [];
if (flextype('registry')->get('plugins.form.settings.load_on_admin')) {
flextype('registry')->set(
'assets.admin.css',
array_merge($adminCSS, [
'project/plugins/form/assets/dist/css/flextype-ui.min.css?v=' . filemtime('project/plugins/form/assets/dist/css/flextype-ui.min.css'),
])
);
}
if (flextype('registry')->get('plugins.form.settings.load_on_site')) {
flextype('registry')->set(
'assets.site.css',
array_merge($siteCSS, [
'project/plugins/form/assets/dist/css/flextype-ui.min.css?v=' . filemtime('project/plugins/form/assets/dist/css/flextype-ui.min.css'),
])
);
}
if (flextype('registry')->get('flextype.settings.locale') === 'en_US') {
$locale = 'en';
} else {
$locale = substr(strtolower(flextype('registry')->get('flextype.settings.locale')), 0, 2);
}
if ($locale !== 'en') {
$trumbowygLocaleJS = 'project/plugins/form/assets/dist/lang/trumbowyg/langs/' . $locale . '.min.js';
$flatpickrLocaleJS = 'project/plugins/form/assets/dist/lang/flatpickr/l10n/' . $locale . '.js';
} else {
$trumbowygLocaleJS = '';
$flatpickrLocaleJS = '';
}
$adminJS = flextype('registry')->has('assets.admin.js') ? flextype('registry')->get('assets.admin.js') : [];
$siteJS = flextype('registry')->has('assets.site.js') ? flextype('registry')->get('assets.site.js') : [];
if (flextype('registry')->get('plugins.form.settings.load_on_admin')) {
flextype('registry')->set(
'assets.admin.js',
array_merge($adminJS, [
'project/plugins/form/assets/dist/js/flextype-ui.min.js?v=' . filemtime('project/plugins/form/assets/dist/js/flextype-ui.min.js'),
$trumbowygLocaleJS,
$flatpickrLocaleJS,
])
);
}
if (flextype('registry')->get('plugins.form.settings.load_on_site')) {
flextype('registry')->set(
'assets.site.js',
array_merge($siteJS, [
'project/plugins/form/assets/dist/js/flextype-ui.min.js?v=' . filemtime('project/plugins/form/assets/dist/js/flextype-ui.min.js'),
$trumbowygLocaleJS,
$flatpickrLocaleJS,
])
);
}