@@ -212,7 +212,7 @@ abstract class DBObject implements iDisplay
212
212
private $ aEventListeners = [];
213
213
private array $ aAllowedTransitions = [];
214
214
215
- private bool $ bStimulusBeingApplied = false ;
215
+ private ? string $ sStimulusBeingApplied = null ;
216
216
217
217
/**
218
218
* DBObject constructor.
@@ -1208,7 +1208,7 @@ final public function DoComputeValues()
1208
1208
if ($ aCallInfo ["function " ] != "ComputeValues " ) continue ;
1209
1209
return ; //skip!
1210
1210
}
1211
- $ this ->FireEventComputeValues ();
1211
+ $ this ->FireEventComputeValues ($ this -> sStimulusBeingApplied );
1212
1212
$ oKPI = new ExecutionKPI ();
1213
1213
$ this ->ComputeValues ();
1214
1214
$ oKPI ->ComputeStatsForExtension ($ this , 'ComputeValues ' );
@@ -2671,7 +2671,7 @@ final public function CheckToWrite($bDoComputeValues = true)
2671
2671
2672
2672
// Ultimate check - ensure DB integrity
2673
2673
$ this ->SetReadOnly ('No modification allowed during CheckToCreate ' );
2674
- $ this ->FireEventCheckToWrite ();
2674
+ $ this ->FireEventCheckToWrite ($ this -> sStimulusBeingApplied );
2675
2675
$ this ->SetReadWrite ();
2676
2676
2677
2677
$ oKPI = new ExecutionKPI ();
@@ -3400,7 +3400,7 @@ public function DBInsertNoReload()
3400
3400
$ this ->OnInsert ();
3401
3401
$ oKPI ->ComputeStatsForExtension ($ this , 'OnInsert ' );
3402
3402
3403
- $ this ->FireEventBeforeWrite ();
3403
+ $ this ->FireEventBeforeWrite (null );
3404
3404
3405
3405
// If not automatically computed, then check that the key is given by the caller
3406
3406
if (!MetaModel::IsAutoIncrementKey ($ sRootClass )) {
@@ -3535,7 +3535,7 @@ public function DBInsertNoReload()
3535
3535
*/
3536
3536
protected function PostInsertActions (): void
3537
3537
{
3538
- $ this ->FireEventAfterWrite ([], true );
3538
+ $ this ->FireEventAfterWrite ([], true , null );
3539
3539
$ oKPI = new ExecutionKPI ();
3540
3540
$ this ->AfterInsert ();
3541
3541
$ oKPI ->ComputeStatsForExtension ($ this , 'AfterInsert ' );
@@ -3643,7 +3643,7 @@ public function DBUpdate()
3643
3643
$ this ->OnUpdate ();
3644
3644
$ oKPI ->ComputeStatsForExtension ($ this , 'OnUpdate ' );
3645
3645
3646
- $ this ->FireEventBeforeWrite ();
3646
+ $ this ->FireEventBeforeWrite ($ this -> sStimulusBeingApplied );
3647
3647
3648
3648
// Freeze the changes at this point
3649
3649
$ this ->InitPreviousValuesForUpdatedAttributes ();
@@ -3854,7 +3854,7 @@ public function DBUpdate()
3854
3854
*/
3855
3855
protected function PostUpdateActions (array $ aChanges ): void
3856
3856
{
3857
- $ this ->FireEventAfterWrite ($ aChanges , false );
3857
+ $ this ->FireEventAfterWrite ($ aChanges , false , $ this -> sStimulusBeingApplied );
3858
3858
$ oKPI = new ExecutionKPI ();
3859
3859
$ this ->AfterUpdate ();
3860
3860
$ oKPI ->ComputeStatsForExtension ($ this , 'AfterUpdate ' );
@@ -3866,9 +3866,9 @@ protected function PostUpdateActions(array $aChanges): void
3866
3866
$ this ->ActivateOnObjectUpdateTriggersForTargetObjects ();
3867
3867
3868
3868
$ sClass = get_class ($ this );
3869
- if ($ this ->bStimulusBeingApplied )
3869
+ if (utils:: IsNotNullOrEmptyString ( $ this ->sStimulusBeingApplied ) )
3870
3870
{
3871
- $ this ->bStimulusBeingApplied = false ;
3871
+ $ this ->sStimulusBeingApplied = null ;
3872
3872
$ sStateAttCode = MetaModel::GetStateAttributeCode ($ sClass );
3873
3873
$ sPreviousState = $ this ->m_aPreviousValuesForUpdatedAttributes [$ sStateAttCode ];
3874
3874
// Change state triggers...
@@ -4604,7 +4604,7 @@ public function ApplyStimulus($sStimulusCode, $bDoNotWrite = false)
4604
4604
}
4605
4605
if ($ bSuccess )
4606
4606
{
4607
- $ this ->bStimulusBeingApplied = true ;
4607
+ $ this ->sStimulusBeingApplied = $ sStimulusCode ;
4608
4608
// Stop watches
4609
4609
foreach (MetaModel::ListAttributeDefs ($ sClass ) as $ sAttCode => $ oAttDef )
4610
4610
{
@@ -6619,15 +6619,15 @@ public function FireEvent(string $sEvent, array $aEventData = array()): void
6619
6619
* @return void
6620
6620
* @since 3.1.0
6621
6621
*/
6622
- protected function FireEventCheckToWrite (): void
6622
+ protected function FireEventCheckToWrite (? string $ sStimulusBeingApplied ): void
6623
6623
{
6624
6624
}
6625
6625
6626
6626
/**
6627
6627
* @return void
6628
6628
* @since 3.1.0
6629
6629
*/
6630
- protected function FireEventBeforeWrite ()
6630
+ protected function FireEventBeforeWrite (? string $ sStimulusBeingApplied )
6631
6631
{
6632
6632
}
6633
6633
@@ -6637,7 +6637,7 @@ protected function FireEventBeforeWrite()
6637
6637
* @return void
6638
6638
* @since 3.1.0
6639
6639
*/
6640
- protected function FireEventAfterWrite (array $ aChanges , bool $ bIsNew ): void
6640
+ protected function FireEventAfterWrite (array $ aChanges , bool $ bIsNew, ? string $ sStimulusBeingApplied ): void
6641
6641
{
6642
6642
}
6643
6643
@@ -6675,7 +6675,7 @@ protected function FireEventAboutToDelete(): void
6675
6675
* @return void
6676
6676
* @since 3.1.0
6677
6677
*/
6678
- protected function FireEventComputeValues (): void
6678
+ protected function FireEventComputeValues (? string $ sStimulusBeingApplied ): void
6679
6679
{
6680
6680
}
6681
6681
0 commit comments