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\Domain\Model\FormMetadata; |
17
|
|
|
use Romm\Formz\Form\FormInterface; |
18
|
|
|
use Romm\Formz\Middleware\Argument\Arguments; |
19
|
|
|
|
20
|
|
|
class PersistenceFetchingArguments extends Arguments |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param string $hash |
24
|
|
|
* @param FormMetadata $metadata |
25
|
|
|
* @param FormInterface $form |
26
|
|
|
*/ |
27
|
|
|
public function __construct($hash, $metadata, $form) |
28
|
|
|
{ |
29
|
|
|
$this->add('hash', $hash); |
30
|
|
|
$this->add('metadata', $metadata); |
31
|
|
|
$this->add('form', $form); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return bool |
36
|
|
|
*/ |
37
|
|
|
public function hashIsValid() |
38
|
|
|
{ |
39
|
|
|
return null !== $this->getHash() |
40
|
|
|
&& null !== $this->getMetadata(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return bool |
45
|
|
|
*/ |
46
|
|
|
public function formWasFound() |
47
|
|
|
{ |
48
|
|
|
return null !== $this->getForm(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return string|null |
53
|
|
|
*/ |
54
|
|
|
public function getHash() |
55
|
|
|
{ |
56
|
|
|
return $this->get('hash')->getValue(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return FormMetadata|null |
61
|
|
|
*/ |
62
|
|
|
public function getMetadata() |
63
|
|
|
{ |
64
|
|
|
return $this->get('metadata')->getValue(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return FormInterface|null |
69
|
|
|
*/ |
70
|
|
|
public function getForm() |
71
|
|
|
{ |
72
|
|
|
return $this->get('form')->getValue(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|