raoul2000 / yii2-workflow

A simple workflow engine for Yii2
BSD 3-Clause "New" or "Revised" License
171 stars 48 forks source link

Preserve event status (isValid) set by other componets #40

Closed michelezucchini closed 7 years ago

michelezucchini commented 7 years ago

In order to preserve how $event->isValid value setted by others componets/behaviours, it's better to change:

public function beforeSaveStatus($event)
{
    $event->isValid = $this->sendToStatusInternal($this->getOwnerStatus(), true);
}

public function beforeDelete($event)
{
    $event->isValid = $this->sendToStatusInternal(null, true);
}

to

$event->isValid&= $this->......

In my situation, i have a softdelete behaviour that set $event->isValid to FALSE to preserve the record, but SimpleWorkflowBehavior set it to TRUE!

And the record was really deleted..

Was it the best way to solve this problem?

raoul2000 commented 7 years ago

hi @michelezucchini good point ! I have merged your PR. Thanks