Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dev 1159 improve structure events #13429

Merged
merged 3 commits into from
Jul 14, 2023

Conversation

brandonkelly
Copy link
Member

Description

  • Adds new EVENT_BEFORE_INSERT_ELEMENT and EVENT_AFTER_INSERT_ELEMENT events to craft\services\Structures
  • Adds craft\events\MoveElementEvent::$targetElementId and getTargetElement(), for getting the target element that the action is being performed in reference to, if any. (These will be null if $element is being prepended/appended to the root of the structure.)
  • Adds craft\events\MoveElementEvent::$action, which will be set to craft\services\Structures::ACTION_PREPEND, ACTION_APPEND, ACTION_PLACE_BEFORE, or ACTION_PLACE_AFTER.
  • craft\events\Structures::EVENT_BEFORE_MOVE_ELEMENT is now cancellable, so setting $isValid to false will prevent the element from getting moved.
  • Deprecates craft\base\Element::beforeMoveInStructure() and afterMoveInStructure(), as well as the EVENT_BEFORE_MOVE_IN_STRUCTURE and EVENT_AFTER_MOVE_IN_STRUCTURE events they trigger, as they were named consistently with craft\services\Structures::EVENT_BEFORE_MOVE_ELEMENT and EVENT_AFTER_MOVE_ELEMENT, however they didn’t behave the same (they were also triggered for insert operations, whereas the service events were only for actual moves).

Related issues

“insert” is a little confusing since there's also MODE_INSERT, which means “use an `INSERT` SQL statement”
@brandonkelly brandonkelly requested a review from a team as a code owner July 14, 2023 17:13
@linear
Copy link

linear bot commented Jul 14, 2023

[ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant