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\Domain\Model; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Domain\Model\DataObject\FormMetadataObject; |
17
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Contains metadata for a form. |
21
|
|
|
* |
22
|
|
|
* It can be used to store arbitrary data that will be persisted from a request |
23
|
|
|
* to another (if the form is bound to at least one persistence service). |
24
|
|
|
* |
25
|
|
|
* The form is identified with a unique hash, which is used to retrieve the |
26
|
|
|
* metadata instance |
27
|
|
|
* . |
28
|
|
|
*/ |
29
|
|
|
class FormMetadata extends AbstractEntity |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $hash; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $className; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $identifier; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \Romm\Formz\Domain\Model\DataObject\FormMetadataObject |
48
|
|
|
*/ |
49
|
|
|
protected $metadata; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var bool |
53
|
|
|
*/ |
54
|
|
|
private $objectWasAssigned = false; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $hash |
58
|
|
|
* @param string $className |
59
|
|
|
* @param string $identifier |
60
|
|
|
* @param FormMetadataObject $metadata |
61
|
|
|
*/ |
62
|
|
|
public function __construct($hash, $className, $identifier, FormMetadataObject $metadata) |
63
|
|
|
{ |
64
|
|
|
$this->hash = $hash; |
65
|
|
|
$this->className = $className; |
66
|
|
|
$this->identifier = $identifier; |
67
|
|
|
$this->metadata = $metadata; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getHash() |
74
|
|
|
{ |
75
|
|
|
return $this->hash; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getIdentifier() |
82
|
|
|
{ |
83
|
|
|
return $this->identifier; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param string $identifier |
88
|
|
|
*/ |
89
|
|
|
public function setIdentifier($identifier) |
90
|
|
|
{ |
91
|
|
|
$this->identifier = $identifier; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function getClassName() |
98
|
|
|
{ |
99
|
|
|
return $this->className; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return bool |
104
|
|
|
*/ |
105
|
|
|
public function hasIdentifier() |
106
|
|
|
{ |
107
|
|
|
return null !== $this->identifier; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return FormMetadataObject |
112
|
|
|
*/ |
113
|
|
|
public function getMetadata() |
114
|
|
|
{ |
115
|
|
|
if (false === $this->objectWasAssigned) { |
116
|
|
|
$this->objectWasAssigned = true; |
117
|
|
|
$this->metadata->setObject($this); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return $this->metadata; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|