|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Anax\HTMLForm; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Container\ContainerInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Base class for form model classes. |
|
9
|
|
|
*/ |
|
10
|
|
|
abstract class FormModel |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var Anax\DI\DIInterface $di the DI/service container. |
|
|
|
|
|
|
14
|
|
|
* @var class $form the main form class. |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $di; |
|
17
|
|
|
protected $form; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Constructor injects with DI container and creates the form. |
|
23
|
|
|
* |
|
24
|
|
|
* @param Psr\Container\ContainerInterface $di a service container |
|
|
|
|
|
|
25
|
|
|
*/ |
|
26
|
|
|
public function __construct(ContainerInterface $di) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->di = $di; |
|
|
|
|
|
|
29
|
|
|
$this->form = new Form($di); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Customise the check() method to use own methods. |
|
36
|
|
|
* |
|
37
|
|
|
* @return boolean|null $callbackStatus if submitted&validates, false if |
|
38
|
|
|
* not validate, null if not submitted. |
|
39
|
|
|
* If submitted the callback function |
|
40
|
|
|
* will return the actual value which |
|
41
|
|
|
* should be true or false. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function check() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->form->check( |
|
46
|
|
|
[$this, "callbackSuccess"], |
|
47
|
|
|
[$this, "callbackFail"] |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Return HTML for the form. |
|
55
|
|
|
* |
|
56
|
|
|
* @param array $options with options affecting the form output. |
|
57
|
|
|
* |
|
58
|
|
|
* @return string with HTML for the form. |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getHTML($options = []) |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->form->getHTML($options); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Callback what to do if the form was successfully submitted, this |
|
69
|
|
|
* happen when the submit callback method returns true. This method |
|
70
|
|
|
* can/should be implemented by the subclass for a different behaviour. |
|
71
|
|
|
*/ |
|
72
|
|
|
public function callbackSuccess() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->di->get("response")->redirectSelf()->send(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Callback what to do if the form was unsuccessfully submitted, this |
|
81
|
|
|
* happen when the submit callback method returns false or if validation |
|
82
|
|
|
* fails. This method can/should be implemented by the subclass for a |
|
83
|
|
|
* different behaviour. |
|
84
|
|
|
*/ |
|
85
|
|
|
public function callbackFail() |
|
86
|
|
|
{ |
|
87
|
|
|
$this->di->get("response")->redirectSelf()->send(); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths