|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (c) 2015 ublaboo <[email protected]> |
|
5
|
|
|
* @author Pavel Janda <[email protected]> |
|
6
|
|
|
* @package Ublaboo |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Ublaboo\DataGrid\Utils; |
|
10
|
|
|
|
|
11
|
|
|
use Nette; |
|
12
|
|
|
use Nette\Forms\Container; |
|
13
|
|
|
|
|
14
|
|
|
final class ItemDetailForm extends Container |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var callable |
|
19
|
|
|
*/ |
|
20
|
|
|
private $callable_set_container; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
private $http_post; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param callable $callable_set_container |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(callable $callable_set_container) |
|
32
|
|
|
{ |
|
33
|
|
|
parent::__construct(); |
|
34
|
|
|
|
|
35
|
|
|
$this->monitor('Nette\Application\UI\Presenter'); |
|
36
|
|
|
|
|
37
|
|
|
$this->callable_set_container = $callable_set_container; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param \Nette\ComponentModel\IContainer |
|
43
|
|
|
*/ |
|
44
|
|
|
protected function attached($presenter) |
|
45
|
|
|
{ |
|
46
|
|
|
parent::attached($presenter); |
|
47
|
|
|
|
|
48
|
|
|
if (!$presenter instanceof Nette\Application\UI\Presenter) { |
|
|
|
|
|
|
49
|
|
|
return; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$this->loadHttpData(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
public function loadHttpData() |
|
60
|
|
|
{ |
|
61
|
|
|
if (!$this->getForm()->isSubmitted()) { |
|
62
|
|
|
return; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
foreach ((array) $this->getHttpData() as $name => $value) { |
|
66
|
|
|
if ((is_array($value) || $value instanceof \Traversable) && !$this->getComponent($name, false)) { |
|
67
|
|
|
$this->getComponent($name); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return mixed|NULL |
|
75
|
|
|
*/ |
|
76
|
|
|
private function getHttpData() |
|
77
|
|
|
{ |
|
78
|
|
|
if ($this->http_post === null) { |
|
79
|
|
|
$path = explode(self::NAME_SEPARATOR, $this->lookupPath('Nette\Forms\Form')); |
|
80
|
|
|
|
|
81
|
|
|
$this->http_post = Nette\Utils\Arrays::get($this->getForm()->getHttpData(), $path, null); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $this->http_post; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @param string $name |
|
90
|
|
|
* @return Container |
|
91
|
|
|
*/ |
|
92
|
|
|
public function offsetGet($name) |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->getComponent($name); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param string $name |
|
100
|
|
|
* @return Container |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getComponent($name) |
|
103
|
|
|
{ |
|
104
|
|
|
$container = $this->addContainer($name); |
|
105
|
|
|
|
|
106
|
|
|
call_user_func($this->callable_set_container, $container); |
|
107
|
|
|
|
|
108
|
|
|
return $container; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.