You are here

public function TransactionType::set in Transaction 8

Sets the value of a property.

Parameters

string $property_name: The name of the property that should be set.

mixed $value: The value the property should be set to.

Return value

$this

Overrides ConfigEntityBase::set

1 call to TransactionType::set()
TransactionType::preSave in src/Entity/TransactionType.php
Acts on an entity before the presave hook is invoked.

File

src/Entity/TransactionType.php, line 320

Class

TransactionType
Provides a type of transaction.

Namespace

Drupal\transaction\Entity

Code

public function set($property_name, $value) {
  if ($property_name === 'bundles') {

    // Sanitize values for bundles.
    $clean_value = [];
    if (is_array($value)) {
      foreach ($value as $item) {
        if (!empty($item) && is_string($item)) {
          $clean_value[] = $item;
        }
      }
    }
    $value = $clean_value;
  }
  return parent::set($property_name, $value);
}