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\Middleware\Item\Persistence; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Form\Service\DataObject\FormIdentifierObject; |
17
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
18
|
|
|
|
19
|
|
|
class PersistenceMiddlewareService implements SingletonInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var FormIdentifierObject |
23
|
|
|
*/ |
24
|
|
|
protected $identifierObject; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Change this flag if the form instance should not be injected in |
28
|
|
|
* persistence at the end of the middleware dispatching process. |
29
|
|
|
* |
30
|
|
|
* @var bool |
31
|
|
|
*/ |
32
|
|
|
protected $injectionFlag = true; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Resets the service states. |
36
|
|
|
*/ |
37
|
|
|
public function reset() |
38
|
|
|
{ |
39
|
|
|
$this->identifierObject = null; |
40
|
|
|
$this->injectionFlag = true; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return FormIdentifierObject |
45
|
|
|
*/ |
46
|
|
|
public function getIdentifierObject() |
47
|
|
|
{ |
48
|
|
|
return $this->identifierObject; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return bool |
53
|
|
|
*/ |
54
|
|
|
public function hasIdentifierObject() |
55
|
|
|
{ |
56
|
|
|
return null !== $this->identifierObject; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param FormIdentifierObject $identifierObject |
61
|
|
|
*/ |
62
|
|
|
public function setIdentifierObject(FormIdentifierObject $identifierObject) |
63
|
|
|
{ |
64
|
|
|
$this->identifierObject = $identifierObject; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function getInjectionFlag() |
71
|
|
|
{ |
72
|
|
|
return $this->injectionFlag; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param bool $injectionFlag |
77
|
|
|
*/ |
78
|
|
|
public function setInjectionFlag($injectionFlag) |
79
|
|
|
{ |
80
|
|
|
$this->injectionFlag = (bool)$injectionFlag; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|