You are here

public function DsTestTrait::entitiesClearFieldSettings in Display Suite 8.2

Utility function to clear field settings.

File

src/Tests/DsTestTrait.php, line 187

Class

DsTestTrait
Provides common functionality for the Display Suite test classes.

Namespace

Drupal\ds\Tests

Code

public function entitiesClearFieldSettings() {
  $display = entity_get_display('node', 'article', 'default');

  // Remove all third party settings from components.
  foreach ($display
    ->getComponents() as $key => $info) {
    $info['third_party_settings'] = array();
    $display
      ->setComponent($key, $info);
  }

  // Remove entity display third party settings.
  $tps = $display
    ->getThirdPartySettings('ds');
  if (!empty($tps)) {
    foreach (array_keys($tps) as $key) {
      $display
        ->unsetThirdPartySetting('ds', $key);
    }
  }

  // Save.
  $display
    ->save();
}