-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more Interfaces, add ModelManager to abstract the persistency layer
- Loading branch information
Thomas Rabaix
committed
Apr 10, 2011
1 parent
f81802b
commit b0df44f
Showing
37 changed files
with
1,239 additions
and
756 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ | |
* | ||
* @author Thomas Rabaix <[email protected]> | ||
*/ | ||
class FieldDescription | ||
abstract class BaseFieldDescription implements FieldDescriptionInterface | ||
{ | ||
|
||
/** | ||
|
@@ -99,7 +99,7 @@ class FieldDescription | |
* @var Admin the related admin instance | ||
*/ | ||
protected $admin; | ||
|
||
/** | ||
* @var Admin the associated admin class if the object is associated to another entity | ||
*/ | ||
|
@@ -127,7 +127,7 @@ public function getFieldName() | |
} | ||
|
||
/** | ||
* Set the name | ||
* Set the name | ||
* | ||
* @param string $name | ||
* @return void | ||
|
@@ -248,7 +248,7 @@ public function setType($type) | |
|
||
/** | ||
* return the type | ||
* | ||
* | ||
* @return int|string | ||
*/ | ||
public function getType() | ||
|
@@ -259,7 +259,7 @@ public function getType() | |
/** | ||
* set the parent Admin (only used in nested admin) | ||
* | ||
* @param Admin $parent | ||
* @param \Sonata\AdminBundle\Admin\Admin $parent | ||
* @return void | ||
*/ | ||
public function setParent(Admin $parent) | ||
|
@@ -270,28 +270,13 @@ public function setParent(Admin $parent) | |
/** | ||
* return the parent Admin (only used in nested admin) | ||
* | ||
* @return Admin | ||
* @return \Sonata\AdminBundle\Admin\Admin | ||
*/ | ||
public function getParent() | ||
{ | ||
return $this->parent; | ||
} | ||
|
||
/** | ||
* Define the association mapping definition | ||
* | ||
* @param array $associationMapping | ||
* @return void | ||
*/ | ||
public function setAssociationMapping(array $associationMapping) | ||
{ | ||
$this->associationMapping = $associationMapping; | ||
|
||
$this->type = $this->type ?: $associationMapping['type']; | ||
$this->mappingType = $this->mappingType ?: $associationMapping['type']; | ||
$this->fieldName = $associationMapping['fieldName']; | ||
} | ||
|
||
/** | ||
* return the association mapping definition | ||
* | ||
|
@@ -302,35 +287,6 @@ public function getAssociationMapping() | |
return $this->associationMapping; | ||
} | ||
|
||
/** | ||
* return the related Target Entity | ||
* | ||
* @return string|null | ||
*/ | ||
public function getTargetEntity() | ||
{ | ||
if ($this->associationMapping) { | ||
return $this->associationMapping['targetEntity']; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* set the field mapping information | ||
* | ||
* @param array $fieldMapping | ||
* @return void | ||
*/ | ||
public function setFieldMapping(array $fieldMapping) | ||
{ | ||
$this->fieldMapping = $fieldMapping; | ||
|
||
$this->type = $this->type ?: $fieldMapping['type']; | ||
$this->mappingType = $this->mappingType ?: $fieldMapping['type']; | ||
$this->fieldName = $this->fieldName ?: $fieldMapping['fieldName']; | ||
} | ||
|
||
/** | ||
* return the field mapping definition | ||
* | ||
|
@@ -344,7 +300,7 @@ public function getFieldMapping() | |
/** | ||
* set the association admin instance (only used if the field is linked to an Admin) | ||
* | ||
* @param Admin $associationAdmin the associated admin | ||
* @param \Sonata\AdminBundle\Admin\Admin $associationAdmin the associated admin | ||
*/ | ||
public function setAssociationAdmin(Admin $associationAdmin) | ||
{ | ||
|
@@ -354,23 +310,13 @@ public function setAssociationAdmin(Admin $associationAdmin) | |
|
||
/** | ||
* return the associated Admin instance (only used if the field is linked to an Admin) | ||
* @return Admin | ||
* @return \Sonata\AdminBundle\Admin\Admin | ||
*/ | ||
public function getAssociationAdmin() | ||
{ | ||
return $this->associationAdmin; | ||
} | ||
|
||
/** | ||
* return true if the FieldDescription is linked to an identifier field | ||
* | ||
* @return bool | ||
*/ | ||
public function isIdentifier() | ||
{ | ||
|
||
return isset($this->fieldMapping['id']) ? $this->fieldMapping['id'] : false; | ||
} | ||
|
||
/** | ||
* return the value linked to the description | ||
|
@@ -389,7 +335,7 @@ public function getValue($object) | |
if (method_exists($object, $getter)) { | ||
|
||
$value = call_user_func(array($object, $getter)); | ||
|
||
} else if ($this->getOption('code') && method_exists($object, $this->getOption('code'))) { | ||
|
||
$value = call_user_func(array($object, $this->getOption('code'))); | ||
|
@@ -401,7 +347,7 @@ public function getValue($object) | |
/** | ||
* set the admin class linked to this FieldDescription | ||
* | ||
* @param Admin $admin | ||
* @param \Sonata\AdminBundle\Admin\Admin $admin | ||
* @return void | ||
*/ | ||
public function setAdmin(Admin $admin) | ||
|
@@ -410,7 +356,7 @@ public function setAdmin(Admin $admin) | |
} | ||
|
||
/** | ||
* @return Admin the admin class linked to this FieldDescription | ||
* @return \Sonata\AdminBundle\Admin\Admin the admin class linked to this FieldDescription | ||
*/ | ||
public function getAdmin() | ||
{ | ||
|
@@ -453,7 +399,7 @@ public function mergeOption($name, array $options = array()) | |
|
||
/** | ||
* merge options values | ||
* | ||
* | ||
* @param array $options | ||
* @return void | ||
*/ | ||
|
Oops, something went wrong.