public function Transaction::setProperty in Transaction 8
Sets a property value.
Parameters
string $key: Property key.
string $value: Value to store. NULL will delete the property.
Return value
\Drupal\transaction\TransactionInterface The called transaction.
Overrides TransactionInterface::setProperty
File
- src/
Entity/ Transaction.php, line 345
Class
- Transaction
- Provides the transaction content entity.
Namespace
Drupal\transaction\EntityCode
public function setProperty($key, $value = NULL) {
$item = $this
->get('properties')
->first() ?: $this
->get('properties')
->appendItem();
$map = $item
->getValue();
if ($value === NULL) {
unset($map[$key]);
}
else {
$map[$key] = $value;
}
$item
->setValue($map);
return $this;
}