1 | <?php |
||
18 | class TbRelationalColumn extends TbDataColumn { |
||
19 | |||
20 | /** |
||
21 | * @var string $url the route to call via AJAX to get the data from |
||
22 | */ |
||
23 | public $url; |
||
24 | |||
25 | /** |
||
26 | * @var string $cssClass the class name that will wrap up the cell content. |
||
27 | * Important Note: this class will be used as the trigger for the AJAX call, so make sure is unique for the |
||
28 | * column. |
||
29 | */ |
||
30 | public $cssClass = 'tbrelational-column'; |
||
31 | |||
32 | /** |
||
33 | * @var bool $cacheData if set to true, there won't be more than one AJAX request. If set to false, the widget will |
||
34 | * continuously make AJAX requests. This is useful if the data could vary. If the data doesn't change then is better |
||
35 | * to set it to true. Defaults to true. |
||
36 | */ |
||
37 | public $cacheData = true; |
||
38 | |||
39 | /** |
||
40 | * @var string|CJavaScriptExpression a javascript function that will be invoked if an AJAX call occurs. |
||
41 | * |
||
42 | * The function signature is <code>function(tr, rowid, data)</code> |
||
43 | * <ul> |
||
44 | * <li><code>tr</code> is the newly created TR HTML object that will display the returned server data.</li> |
||
45 | * <li><code>rowid</code> the model id of the row.</li> |
||
46 | * <li><code>data</code> is the data returned by the server that is already displayed on the row.</li> |
||
47 | * </ul> |
||
48 | * Note: This handler is not called for JSONP requests. |
||
49 | * |
||
50 | * Example (add in a call to TbRelationalColumn): |
||
51 | * <pre> |
||
52 | * ... |
||
53 | * 'afterAjaxUpdate'=>'js:function(tr,rowid, data){ console.log(rowid); }', |
||
54 | * ... |
||
55 | * </pre> |
||
56 | */ |
||
57 | public $afterAjaxUpdate; |
||
58 | |||
59 | /** |
||
60 | * @var string $ajaxErrorMessage the message that is displayed on the newly created row in case there is an AJAX |
||
61 | * error. |
||
62 | */ |
||
63 | public $ajaxErrorMessage = 'Error'; |
||
64 | |||
65 | /** |
||
66 | * @var array $submitData allows you to merge extra data into the query string being sent to the server. |
||
67 | * normally the row id is sent as 'id' |
||
68 | */ |
||
69 | public $submitData=array(); |
||
70 | |||
71 | /** |
||
72 | * widget initialization |
||
73 | */ |
||
74 | public function init() { |
||
83 | |||
84 | /** |
||
85 | * Overrides CDataColumn renderDataCell in order to wrap up its content with the object that will be used as a |
||
86 | * trigger. |
||
87 | * Important: Making use of links as a content for this of column is an error. |
||
88 | * |
||
89 | * @param int $row |
||
90 | */ |
||
91 | public function renderDataCell($row) { |
||
92 | |||
93 | $data = $this->grid->dataProvider->data[$row]; |
||
94 | $options = $this->htmlOptions; |
||
95 | |||
96 | if ($this->cssClassExpression !== null) { |
||
97 | $class = $this->evaluateExpression($this->cssClassExpression, array('row' => $row, 'data' => $data)); |
||
98 | if (isset($options['class'])) { |
||
99 | $options['class'] .= ' ' . $class; |
||
100 | } else { |
||
101 | $options['class'] = $class; |
||
102 | } |
||
103 | } |
||
104 | |||
105 | echo CHtml::openTag('td', $options); |
||
106 | echo CHtml::openTag('span', array('class' => $this->cssClass.'_'.$this->id, 'data-rowid' => $this->getPrimaryKey($data), 'data-colid' => $this->id)); |
||
107 | $this->renderDataCellContent($row, $data); |
||
108 | echo CHtml::closeTag('span'); |
||
109 | echo CHtml::closeTag('td'); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Helper function to return the primary key of the $data |
||
114 | * * IMPORTANT: composite keys on CActiveDataProviders will return the keys joined by two dashes: `--` |
||
115 | * |
||
116 | * @param CActiveRecord $data |
||
117 | * |
||
118 | * @return null|string |
||
119 | */ |
||
120 | protected function getPrimaryKey($data) { |
||
135 | |||
136 | /** |
||
137 | * Register script that will handle its behavior |
||
138 | */ |
||
139 | public function registerClientScript() { |
||
230 | } |
||
231 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to 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
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.