mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX for #4129: Ensure belongsToComponent() and hasManyComponent() methods return null instead of false, to be consistent with other relation component methods.
This commit is contained in:
parent
72a284c9b8
commit
cadc02b63b
@ -1857,7 +1857,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @param string $component
|
* @param string $component
|
||||||
* @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have
|
* @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have
|
||||||
* the field data stripped off. It defaults to TRUE.
|
* the field data stripped off. It defaults to TRUE.
|
||||||
* @return string|false
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function belongsToComponent($component, $classOnly = true) {
|
public function belongsToComponent($component, $classOnly = true) {
|
||||||
$belongsTo = (array)Config::inst()->get($this->class, 'belongs_to', Config::INHERITED);
|
$belongsTo = (array)Config::inst()->get($this->class, 'belongs_to', Config::INHERITED);
|
||||||
@ -1865,7 +1865,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
if($belongsTo && array_key_exists($component, $belongsTo)) {
|
if($belongsTo && array_key_exists($component, $belongsTo)) {
|
||||||
$belongsTo = $belongsTo[$component];
|
$belongsTo = $belongsTo[$component];
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $belongsTo) : $belongsTo;
|
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $belongsTo) : $belongsTo;
|
||||||
@ -1955,7 +1955,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @param string $component
|
* @param string $component
|
||||||
* @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have
|
* @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have
|
||||||
* the field data stripped off. It defaults to TRUE.
|
* the field data stripped off. It defaults to TRUE.
|
||||||
* @return string|false
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function hasManyComponent($component, $classOnly = true) {
|
public function hasManyComponent($component, $classOnly = true) {
|
||||||
$hasMany = (array)Config::inst()->get($this->class, 'has_many', Config::INHERITED);
|
$hasMany = (array)Config::inst()->get($this->class, 'has_many', Config::INHERITED);
|
||||||
@ -1963,7 +1963,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
if($hasMany && array_key_exists($component, $hasMany)) {
|
if($hasMany && array_key_exists($component, $hasMany)) {
|
||||||
$hasMany = $hasMany[$component];
|
$hasMany = $hasMany[$component];
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $hasMany) : $hasMany;
|
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $hasMany) : $hasMany;
|
||||||
|
Loading…
Reference in New Issue
Block a user