Skip to content

Commit

Permalink
EVENT_BEFORE_BULK_OP
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 13, 2023
1 parent 287905c commit b70b60a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,20 @@ class Elements extends Component
*/
public const EVENT_BEFORE_EAGER_LOAD_ELEMENTS = 'beforeEagerLoadElements';

/**
* @event Event The event that is triggered before a bulk element operation has started.
*
* Note that this won’t necessarily fire from the same request as [[EVENT_AFTER_BULK_OP]].
*
* @since 5.0.0
*/
public const EVENT_BEFORE_BULK_OP = 'afterBulkOp';

/**
* @event Event The event that is triggered after a bulk element operation is completed.
*
* Note that this won’t necessarily fire from the same request as [[EVENT_BEFORE_BULK_OP]].
*
* @since 5.0.0
*/
public const EVENT_AFTER_BULK_OP = 'afterBulkOp';
Expand Down Expand Up @@ -1057,6 +1069,13 @@ public function getEnabledSiteIdsForElement(int $elementId): array
public function beginBulkOp(): string
{
$key = StringHelper::randomString(10);

if ($this->hasEventHandlers(self::EVENT_BEFORE_BULK_OP)) {
$this->trigger(self::EVENT_BEFORE_BULK_OP, new BulkElementOpEvent([
'key' => $key,
]));
}

$this->resumeBulkOp($key);
return $key;
}
Expand Down

0 comments on commit b70b60a

Please sign in to comment.