You are here

public function DsAttribute::mergeAttributes in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/DsAttribute.php \Drupal\ds\DsAttribute::mergeAttributes()
  2. 8.3 src/DsAttribute.php \Drupal\ds\DsAttribute::mergeAttributes()

Merges Attributes objects into another one.

Return value

\Drupal\ds\DsAttribute Merged attributes.

File

src/DsAttribute.php, line 18

Class

DsAttribute
Extends the core Attribute object.

Namespace

Drupal\ds

Code

public function mergeAttributes() {
  $args = func_get_args();
  if ($args) {
    $merged_array = $this
      ->toArray();
    foreach ($args as $arg) {
      if (is_object($arg)) {
        $merged_array = array_merge_recursive($merged_array, $arg
          ->toArray());
      }
    }
    foreach ($merged_array as $attribute => $value) {
      $this
        ->setAttribute($attribute, $value);
    }
  }
  return $this;
}