47
47
*
48
48
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
49
49
*/
50
- class FieldDescription
50
+ abstract class BaseFieldDescription implements FieldDescriptionInterface
51
51
{
52
52
53
53
/**
@@ -99,7 +99,7 @@ class FieldDescription
99
99
* @var Admin the related admin instance
100
100
*/
101
101
protected $ admin ;
102
-
102
+
103
103
/**
104
104
* @var Admin the associated admin class if the object is associated to another entity
105
105
*/
@@ -127,7 +127,7 @@ public function getFieldName()
127
127
}
128
128
129
129
/**
130
- * Set the name
130
+ * Set the name
131
131
*
132
132
* @param string $name
133
133
* @return void
@@ -248,7 +248,7 @@ public function setType($type)
248
248
249
249
/**
250
250
* return the type
251
- *
251
+ *
252
252
* @return int|string
253
253
*/
254
254
public function getType ()
@@ -259,7 +259,7 @@ public function getType()
259
259
/**
260
260
* set the parent Admin (only used in nested admin)
261
261
*
262
- * @param Admin $parent
262
+ * @param \Sonata\AdminBundle\Admin\ Admin $parent
263
263
* @return void
264
264
*/
265
265
public function setParent (Admin $ parent )
@@ -270,28 +270,13 @@ public function setParent(Admin $parent)
270
270
/**
271
271
* return the parent Admin (only used in nested admin)
272
272
*
273
- * @return Admin
273
+ * @return \Sonata\AdminBundle\Admin\ Admin
274
274
*/
275
275
public function getParent ()
276
276
{
277
277
return $ this ->parent ;
278
278
}
279
279
280
- /**
281
- * Define the association mapping definition
282
- *
283
- * @param array $associationMapping
284
- * @return void
285
- */
286
- public function setAssociationMapping (array $ associationMapping )
287
- {
288
- $ this ->associationMapping = $ associationMapping ;
289
-
290
- $ this ->type = $ this ->type ?: $ associationMapping ['type ' ];
291
- $ this ->mappingType = $ this ->mappingType ?: $ associationMapping ['type ' ];
292
- $ this ->fieldName = $ associationMapping ['fieldName ' ];
293
- }
294
-
295
280
/**
296
281
* return the association mapping definition
297
282
*
@@ -302,35 +287,6 @@ public function getAssociationMapping()
302
287
return $ this ->associationMapping ;
303
288
}
304
289
305
- /**
306
- * return the related Target Entity
307
- *
308
- * @return string|null
309
- */
310
- public function getTargetEntity ()
311
- {
312
- if ($ this ->associationMapping ) {
313
- return $ this ->associationMapping ['targetEntity ' ];
314
- }
315
-
316
- return null ;
317
- }
318
-
319
- /**
320
- * set the field mapping information
321
- *
322
- * @param array $fieldMapping
323
- * @return void
324
- */
325
- public function setFieldMapping (array $ fieldMapping )
326
- {
327
- $ this ->fieldMapping = $ fieldMapping ;
328
-
329
- $ this ->type = $ this ->type ?: $ fieldMapping ['type ' ];
330
- $ this ->mappingType = $ this ->mappingType ?: $ fieldMapping ['type ' ];
331
- $ this ->fieldName = $ this ->fieldName ?: $ fieldMapping ['fieldName ' ];
332
- }
333
-
334
290
/**
335
291
* return the field mapping definition
336
292
*
@@ -344,7 +300,7 @@ public function getFieldMapping()
344
300
/**
345
301
* set the association admin instance (only used if the field is linked to an Admin)
346
302
*
347
- * @param Admin $associationAdmin the associated admin
303
+ * @param \Sonata\AdminBundle\Admin\ Admin $associationAdmin the associated admin
348
304
*/
349
305
public function setAssociationAdmin (Admin $ associationAdmin )
350
306
{
@@ -354,23 +310,13 @@ public function setAssociationAdmin(Admin $associationAdmin)
354
310
355
311
/**
356
312
* return the associated Admin instance (only used if the field is linked to an Admin)
357
- * @return Admin
313
+ * @return \Sonata\AdminBundle\Admin\ Admin
358
314
*/
359
315
public function getAssociationAdmin ()
360
316
{
361
317
return $ this ->associationAdmin ;
362
318
}
363
319
364
- /**
365
- * return true if the FieldDescription is linked to an identifier field
366
- *
367
- * @return bool
368
- */
369
- public function isIdentifier ()
370
- {
371
-
372
- return isset ($ this ->fieldMapping ['id ' ]) ? $ this ->fieldMapping ['id ' ] : false ;
373
- }
374
320
375
321
/**
376
322
* return the value linked to the description
@@ -389,7 +335,7 @@ public function getValue($object)
389
335
if (method_exists ($ object , $ getter )) {
390
336
391
337
$ value = call_user_func (array ($ object , $ getter ));
392
-
338
+
393
339
} else if ($ this ->getOption ('code ' ) && method_exists ($ object , $ this ->getOption ('code ' ))) {
394
340
395
341
$ value = call_user_func (array ($ object , $ this ->getOption ('code ' )));
@@ -401,7 +347,7 @@ public function getValue($object)
401
347
/**
402
348
* set the admin class linked to this FieldDescription
403
349
*
404
- * @param Admin $admin
350
+ * @param \Sonata\AdminBundle\Admin\ Admin $admin
405
351
* @return void
406
352
*/
407
353
public function setAdmin (Admin $ admin )
@@ -410,7 +356,7 @@ public function setAdmin(Admin $admin)
410
356
}
411
357
412
358
/**
413
- * @return Admin the admin class linked to this FieldDescription
359
+ * @return \Sonata\AdminBundle\Admin\ Admin the admin class linked to this FieldDescription
414
360
*/
415
361
public function getAdmin ()
416
362
{
@@ -453,7 +399,7 @@ public function mergeOption($name, array $options = array())
453
399
454
400
/**
455
401
* merge options values
456
- *
402
+ *
457
403
* @param array $options
458
404
* @return void
459
405
*/
0 commit comments