You are here

public function ConfigSnapshot::save in Config Snapshot 8

Saves an entity permanently.

When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.

Overrides ConfigEntityBase::save

File

src/Entity/ConfigSnapshot.php, line 161

Class

ConfigSnapshot
Defines the Config snapshot entity.

Namespace

Drupal\config_snapshot\Entity

Code

public function save() {
  $collections = array_column($this->items, 'collection');
  $names = array_column($this->items, 'name');

  // Sort the items by collection then by name.
  array_multisort($collections, SORT_ASC, $names, SORT_ASC, $this->items);
  parent::save();
}