1212
1313namespace APY \DataGridBundle \Grid \Source ;
1414
15- use APY \DataGridBundle \Grid \Column ;
15+ use APY \DataGridBundle \Grid \Column \ArrayColumn ;
16+ use APY \DataGridBundle \Grid \Column \BooleanColumn ;
17+ use APY \DataGridBundle \Grid \Column \Column ;
18+ use APY \DataGridBundle \Grid \Column \DateColumn ;
19+ use APY \DataGridBundle \Grid \Column \DateTimeColumn ;
20+ use APY \DataGridBundle \Grid \Column \NumberColumn ;
21+ use APY \DataGridBundle \Grid \Column \TextColumn ;
22+ use APY \DataGridBundle \Grid \Column \UntypedColumn ;
23+ use APY \DataGridBundle \Grid \Rows ;
1624
1725/**
1826 * Vector is really an Array.
@@ -45,6 +53,7 @@ class Vector extends Source
4553 * Creates the Vector and sets its data.
4654 *
4755 * @param array $data
56+ * @param array $columns
4857 */
4958 public function __construct (array $ data , array $ columns = [])
5059 {
@@ -78,7 +87,7 @@ protected function guessColumns()
7887 'visible ' => true ,
7988 'field ' => $ id ,
8089 ];
81- $ guessedColumns [] = new Column \ UntypedColumn ($ params );
90+ $ guessedColumns [] = new UntypedColumn ($ params );
8291 }
8392 }
8493
@@ -88,7 +97,7 @@ protected function guessColumns()
8897 $ iteration = min (10 , count ($ this ->data ));
8998
9099 foreach ($ this ->columns as $ c ) {
91- if (!$ c instanceof Column \ UntypedColumn) {
100+ if (!$ c instanceof UntypedColumn) {
92101 continue ;
93102 }
94103
@@ -152,26 +161,26 @@ public function getColumns($columns)
152161 $ token = empty ($ this ->id ); //makes the first column primary by default
153162
154163 foreach ($ this ->columns as $ c ) {
155- if ($ c instanceof Column \ UntypedColumn) {
164+ if ($ c instanceof UntypedColumn) {
156165 switch ($ c ->getType ()) {
157166 case 'date ' :
158- $ column = new Column \ DateColumn ($ c ->getParams ());
167+ $ column = new DateColumn ($ c ->getParams ());
159168 break ;
160169 case 'datetime ' :
161- $ column = new Column \ DateTimeColumn ($ c ->getParams ());
170+ $ column = new DateTimeColumn ($ c ->getParams ());
162171 break ;
163172 case 'boolean ' :
164- $ column = new Column \ BooleanColumn ($ c ->getParams ());
173+ $ column = new BooleanColumn ($ c ->getParams ());
165174 break ;
166175 case 'number ' :
167- $ column = new Column \ NumberColumn ($ c ->getParams ());
176+ $ column = new NumberColumn ($ c ->getParams ());
168177 break ;
169178 case 'array ' :
170- $ column = new Column \ ArrayColumn ($ c ->getParams ());
179+ $ column = new ArrayColumn ($ c ->getParams ());
171180 break ;
172181 case 'text ' :
173182 default :
174- $ column = new Column \ TextColumn ($ c ->getParams ());
183+ $ column = new TextColumn ($ c ->getParams ());
175184 break ;
176185 }
177186 } else {
@@ -192,9 +201,10 @@ public function getColumns($columns)
192201 * @param \APY\DataGridBundle\Grid\Column\Column[] $columns
193202 * @param int $page Page Number
194203 * @param int $limit Rows Per Page
204+ * @param int $maxResults Max rows
195205 * @param int $gridDataJunction Grid data junction
196206 *
197- * @return \APY\DataGridBundle\Grid\ Rows
207+ * @return Rows
198208 */
199209 public function execute ($ columns , $ page = 0 , $ limit = 0 , $ maxResults = null , $ gridDataJunction = Column::DATA_CONJUNCTION )
200210 {
@@ -226,6 +236,14 @@ public function setId($id)
226236 $ this ->id = $ id ;
227237 }
228238
239+ /**
240+ * @return mixed
241+ */
242+ public function getId ()
243+ {
244+ return $ this ->id ;
245+ }
246+
229247 /**
230248 * Set a two-dimentional array.
231249 *
@@ -241,12 +259,14 @@ public function setData($data)
241259 throw new \InvalidArgumentException ('Data should be an array with content ' );
242260 }
243261
262+ // This seems to exclude ...
244263 if (is_object (reset ($ this ->data ))) {
245264 foreach ($ this ->data as $ key => $ object ) {
246265 $ this ->data [$ key ] = (array ) $ object ;
247266 }
248267 }
249268
269+ // ... this other (or vice versa)
250270 $ firstRaw = reset ($ this ->data );
251271 if (!is_array ($ firstRaw ) || empty ($ firstRaw )) {
252272 throw new \InvalidArgumentException ('Data should be a two-dimentional array ' );
@@ -272,13 +292,4 @@ protected function hasColumn($id)
272292
273293 return false ;
274294 }
275-
276- protected function getColumn ($ id )
277- {
278- foreach ($ this ->columns as $ c ) {
279- if ($ id === $ c ->getId ()) {
280- return $ c ;
281- }
282- }
283- }
284295}
0 commit comments