public function BusinessRule::save in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Entity/BusinessRule.php \Drupal\business_rules\Entity\BusinessRule::save()
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/ BusinessRule.php, line 192
Class
- BusinessRule
- Defines the Rule entity.
Namespace
Drupal\business_rules\EntityCode
public function save() {
// Only save items on the same context as the Business Rule.
$context_items = [];
if (count($this->items)) {
foreach ($this->items as $key => $item) {
if (!$item instanceof BusinessRulesItemObject) {
$item = new BusinessRulesItemObject($item['id'], $item['type'], $item['weight']);
}
if ($this
->checkItemContext($item)) {
$context_items[$key] = $item
->toArray()[$key];
}
}
}
$this->items = $context_items;
return parent::save();
}