1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2017 Romain CANON <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
7
|
|
|
* under the terms of the GNU General Public License, either |
8
|
|
|
* version 3 of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, see: |
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Romm\Formz\AssetHandler\Connector; |
15
|
|
|
|
16
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Contains several information regarding assets. There can be only one instance |
20
|
|
|
* of this class, so it can be used to store data for several connectors. |
21
|
|
|
*/ |
22
|
|
|
class AssetHandlerConnectorStates implements SingletonInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
private $defaultAssetsIncluded = false; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Storage for JavaScript files which were already included. It will handle |
31
|
|
|
* multiple instance of forms in the same page, by avoiding multiple |
32
|
|
|
* inclusions of the same JavaScript files. |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
private $alreadyIncludedValidationJavaScriptFiles = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param bool $flag |
40
|
|
|
*/ |
41
|
|
|
public function markDefaultAssetsAsIncluded($flag = true) |
42
|
|
|
{ |
43
|
|
|
$this->defaultAssetsIncluded = (bool)$flag; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
|
|
public function defaultAssetsWereIncluded() |
50
|
|
|
{ |
51
|
|
|
return $this->defaultAssetsIncluded; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function getAlreadyIncludedValidationJavaScriptFiles() |
58
|
|
|
{ |
59
|
|
|
return $this->alreadyIncludedValidationJavaScriptFiles; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Saves a file path as already included, so it can be retrieved later and |
64
|
|
|
* not being included twice. |
65
|
|
|
* |
66
|
|
|
* @param string $file |
67
|
|
|
*/ |
68
|
|
|
public function registerIncludedValidationJavaScriptFiles($file) |
69
|
|
|
{ |
70
|
|
|
$this->alreadyIncludedValidationJavaScriptFiles[] = $file; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|