Skip to content
Snippets Groups Projects

Use isEmpty() method instead of empty() function

1 file
+ 14
11
Compare changes
  • Side-by-side
  • Inline
@@ -221,21 +221,24 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
/**
* Retrieve inherited data.
*
* @return string
* @return array
* The inherited data.
*/
protected function inheritData() {
$source_entity = $this->getSourceEntity();
if ($source_entity === FALSE) {
if ($source_entity === FALSE
|| $source_entity->{$this->getSourceField()}->isEmpty()
) {
return [];
}
return $source_entity->{$this->getSourceField()}->getValue() ?? '';
return $source_entity->{$this->getSourceField()}->getValue();
}
/**
* Retrieve prepended data.
*
* @return string
* @return array
* The prepended data.
*/
protected function prependData() {
@@ -247,10 +250,10 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
return $values;
}
if (!empty($destination_entity->{$this->getDestinationField()}->getValue())) {
if (!$destination_entity->{$this->getDestinationField()}->isEmpty()) {
$values = array_merge($values, $destination_entity->{$this->getDestinationField()}->getValue());
}
if (!empty($source_entity->{$this->getSourceField()}->getValue())) {
if (!$source_entity->{$this->getSourceField()}->isEmpty()) {
$values = array_merge($values, $source_entity->{$this->getSourceField()}->getValue());
}
return $values;
@@ -271,10 +274,10 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
return $values;
}
if (!empty($source_entity->{$this->getSourceField()}->getValue())) {
if (!$source_entity->{$this->getSourceField()}->isEmpty()) {
$values = array_merge($values, $source_entity->{$this->getSourceField()}->getValue());
}
if (!empty($destination_entity->{$this->getDestinationField()}->getValue())) {
if (!$destination_entity->{$this->getDestinationField()}->isEmpty()) {
$values = array_merge($values, $destination_entity->{$this->getDestinationField()}->getValue());
}
return $values;
@@ -283,7 +286,7 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
/**
* Retrieve fallback data.
*
* @return string
* @return array
* The fallback data.
*/
protected function fallbackData() {
@@ -295,10 +298,10 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
return $values;
}
if (!empty($destination_entity->{$this->getDestinationField()}->getValue())) {
if (!$destination_entity->{$this->getDestinationField()}->isEmpty()) {
$values = $destination_entity->{$this->getDestinationField()}->getValue();
}
elseif (!empty($source_entity->{$this->getSourceField()}->getValue())) {
elseif (!$source_entity->{$this->getSourceField()}->isEmpty()) {
$values = $source_entity->{$this->getSourceField()}->getValue();
}
return $values;
Loading