You are here

public function TransactionType::preSave in Transaction 8

Acts on an entity before the presave hook is invoked.

Used before the entity is saved and before invoking the presave hook.

Ensure that config entities which are bundles of other entities cannot have their ID changed.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

Throws

\Drupal\Core\Config\ConfigNameException Thrown when attempting to rename a bundle entity.

Overrides ConfigEntityBundleBase::preSave

File

src/Entity/TransactionType.php, line 245

Class

TransactionType
Provides a type of transaction.

Namespace

Drupal\transaction\Entity

Code

public function preSave(EntityStorageInterface $storage) {
  parent::preSave($storage);

  // Sort bundles.
  $bundles = array_filter($this
    ->get('bundles'));
  sort($bundles);
  $this
    ->set('bundles', $bundles);
}