-
-
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.
Deprecate mapping setters from FieldDescriptionInterface (#6648)
Mapping should not be changed in the FieldDescriptionInterface once it is set, deprecating these methods forces to set these mapping attributes when constructing the object.
- Loading branch information
Showing
6 changed files
with
121 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -59,6 +59,10 @@ | |
* - field_options (o): the options to give to the widget | ||
* | ||
* @author Thomas Rabaix <[email protected]> | ||
* | ||
* @method void setFieldMapping(array $fieldMapping) | ||
* @method void setAssociationMapping(array $associationMapping) | ||
* @method void setParentAssociationMappings(array $parentAssociationMappings) | ||
*/ | ||
abstract class BaseFieldDescription implements FieldDescriptionInterface | ||
{ | ||
|
@@ -83,17 +87,17 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface | |
protected $fieldName; | ||
|
||
/** | ||
* @var array the ORM association mapping | ||
* @var array the association mapping | ||
*/ | ||
protected $associationMapping = []; | ||
|
||
/** | ||
* @var array the ORM field information | ||
* @var array the field information | ||
*/ | ||
protected $fieldMapping = []; | ||
|
||
/** | ||
* @var array the ORM parent mapping association | ||
* @var array the parent mapping association | ||
*/ | ||
protected $parentAssociationMappings = []; | ||
|
||
|
@@ -135,8 +139,13 @@ abstract class BaseFieldDescription implements FieldDescriptionInterface | |
/** | ||
* NEXT_MAJOR: Remove the null default value and restrict param type to `string`. | ||
*/ | ||
public function __construct(?string $name = null, array $options = []) | ||
{ | ||
public function __construct( | ||
?string $name = null, | ||
array $options = [], | ||
array $fieldMapping = [], | ||
array $associationMapping = [], | ||
array $parentAssociationMappings = [] | ||
) { | ||
// NEXT_MAJOR: Remove this check and keep the else part. | ||
if (null === $name) { | ||
@trigger_error(sprintf( | ||
|
@@ -149,8 +158,25 @@ public function __construct(?string $name = null, array $options = []) | |
} | ||
|
||
$this->setOptions($options); | ||
|
||
if ([] !== $fieldMapping) { | ||
$this->setFieldMapping($fieldMapping); | ||
} | ||
|
||
if ([] !== $associationMapping) { | ||
$this->setAssociationMapping($associationMapping); | ||
} | ||
|
||
if ([] !== $parentAssociationMappings) { | ||
$this->setParentAssociationMappings($parentAssociationMappings); | ||
} | ||
} | ||
|
||
// NEXT_MAJOR: Uncomment the following lines. | ||
// abstract protected function setFieldMapping(array $fieldMapping): void; | ||
// abstract protected function setAssociationMapping(array $associationMapping): void; | ||
// abstract protected function setParentAssociationMappings(array $parentAssociationMappings): void; | ||
|
||
public function setFieldName($fieldName) | ||
{ | ||
$this->fieldName = $fieldName; | ||
|
@@ -438,8 +464,18 @@ public function mergeOptions(array $options = []) | |
$this->setOptions(array_merge_recursive($this->options, $options)); | ||
} | ||
|
||
/** | ||
* NEXT_MAJOR: Remove this method. | ||
* | ||
* @deprecated since sonata-project/admin-bundle 3.x and will be removed in 4.0. | ||
*/ | ||
public function setMappingType($mappingType) | ||
{ | ||
@trigger_error(sprintf( | ||
'The "%s()" method is deprecated since version 3.x and will be removed in 4.0.', | ||
__METHOD__ | ||
), E_USER_DEPRECATED); | ||
|
||
$this->mappingType = $mappingType; | ||
} | ||
|
||
|
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
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