Skip to content

Commit f3353ef

Browse files
committed
Structure event cleanup
Reverts deprecations made in #13429 Renames the *MOVE* Structures service events to *UPDATE*, so “move” can be left as a generic word that could mean insert or update.
1 parent 5ffa170 commit f3353ef

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

CHANGELOG-WIP.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@
5858
- Added `craft\services\ElementSources::getPages()`. ([#17779](https://github.com/craftcms/cms/pull/17779))
5959
- Added `craft\services\ElementSources::pageExists()`. ([#17779](https://github.com/craftcms/cms/pull/17779))
6060
- Added `craft\services\ElementSources::pageNameId()`. ([#17779](https://github.com/craftcms/cms/pull/17779))
61+
- Added `craft\services\Structure::EVENT_AFTER_UPDATE_ELEMENT`.
62+
- Added `craft\services\Structure::EVENT_BEFORE_UPDATE_ELEMENT`.
6163
- Added `craft\web\GqlResponseFormatter`.
6264
- Added `craft\web\Response::FORMAT_GQL`.
6365
- Added `craft\web\twig\nodes\BaseNode`.
6466
- Added `Craft.BaseElementIndex::asyncSelectDefaultSource()`.
6567
- Added `Craft.BaseElementIndex::asyncSelectSource()`.
6668
- Added `Craft.BaseElementIndex::asyncSelectSourceByKey()`.
6769
- Added `Craft.BaseElementIndex::ensureSourceAttributeInfo()`.
70+
- `craft\base\Element::EVENT_AFTER_MOVE_IN_STRUCTURE` is no longer deprecated.
71+
- `craft\base\Element::EVENT_BEFORE_MOVE_IN_STRUCTURE` is no longer deprecated.
72+
- `craft\base\ElementInterface::afterMoveInStructure()` is no longer deprecated.
73+
- `craft\base\ElementInterface::beforeMoveInStructure()` is no longer deprecated.
6874
- `craft\base\ElementInterface::cardAttributes()` now has a `$fieldLayout` argument. ([#17920](https://github.com/craftcms/cms/pull/17920))
75+
- `craft\events\ElementStructureEvent` is no longer deprecated.
6976
- `craft\helpers\FileHelper::writeToFile()` now throws an exception if the file path isn’t writable, or there isn’t sufficient free space on the disk. ([#17762](https://github.com/craftcms/cms/pull/17762))
7077
- `craft\helpers\UrlHelper` now encodes square brackets in generated URLs. ([#17840](https://github.com/craftcms/cms/pull/17840))
7178
- `craft\services\ElementSources::getSources()` now has a `$page` argument. ([#17779](https://github.com/craftcms/cms/pull/17779))
@@ -74,6 +81,8 @@
7481
- `craft\web\Request::getAcceptsJson()` now returns `true` for requests with `Content-Type` headers that match `application/*+json`, in addition to `application/json`.
7582
- Deprecated `craft\fields\BaseRelationField::$showCardsInGrid`.
7683
- Deprecated `craft\fields\Matrix::$showCardsInGrid`.
84+
- Deprecated `craft\services\Structure::EVENT_AFTER_MOVE_ELEMENT`. `EVENT_AFTER_UPDATE_ELEMENT` should be used instead.
85+
- Deprecated `craft\services\Structure::EVENT_BEFORE_MOVE_ELEMENT`. `EVENT_BEFORE_UPDATE_ELEMENT` should be used instead.
7786
- Deprecated `Craft.BaseElementIndex::selectDefaultSource()`.
7887
- Deprecated `Craft.BaseElementIndex::selectSource()`.
7988
- Deprecated `Craft.BaseElementIndex::selectSourceByKey()`.

src/base/Element.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,18 +785,11 @@ abstract class Element extends Component implements ElementInterface
785785
* @event ElementStructureEvent The event that is triggered before the element is moved in a structure.
786786
*
787787
* You may set [[\yii\base\ModelEvent::$isValid]] to `false` to prevent the element from getting moved.
788-
*
789-
* @deprecated in 4.5.0. [[\craft\services\Structures::EVENT_BEFORE_INSERT_ELEMENT]] or
790-
* [[\craft\services\Structures::EVENT_BEFORE_MOVE_ELEMENT|EVENT_BEFORE_MOVE_ELEMENT]]
791-
* should be used instead.
792788
*/
793789
public const EVENT_BEFORE_MOVE_IN_STRUCTURE = 'beforeMoveInStructure';
794790

795791
/**
796792
* @event ElementStructureEvent The event that is triggered after the element is moved in a structure.
797-
* @deprecated in 4.5.0. [[\craft\services\Structures::EVENT_AFTER_INSERT_ELEMENT]] or
798-
* [[\craft\services\Structures::EVENT_AFTER_MOVE_ELEMENT|EVENT_AFTER_MOVE_ELEMENT]]
799-
* should be used instead.
800793
*/
801794
public const EVENT_AFTER_MOVE_IN_STRUCTURE = 'afterMoveInStructure';
802795

src/base/ElementInterface.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,19 +1912,13 @@ public function afterRestore(): void;
19121912
*
19131913
* @param int $structureId The structure ID
19141914
* @return bool Whether the element should be moved within the structure
1915-
* @deprecated in 4.5.0. [[\craft\services\Structures::EVENT_BEFORE_INSERT_ELEMENT]] or
1916-
* [[\craft\services\Structures::EVENT_BEFORE_MOVE_ELEMENT|EVENT_BEFORE_MOVE_ELEMENT]]
1917-
* should be used instead.
19181915
*/
19191916
public function beforeMoveInStructure(int $structureId): bool;
19201917

19211918
/**
19221919
* Performs actions after an element is moved within a structure.
19231920
*
19241921
* @param int $structureId The structure ID
1925-
* @deprecated in 4.5.0. [[\craft\services\Structures::EVENT_AFTER_INSERT_ELEMENT]] or
1926-
* [[\craft\services\Structures::EVENT_AFTER_MOVE_ELEMENT|EVENT_AFTER_MOVE_ELEMENT]]
1927-
* should be used instead.
19281922
*/
19291923
public function afterMoveInStructure(int $structureId): void;
19301924

src/events/ElementStructureEvent.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
*
1313
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
1414
* @since 3.0.0
15-
* @deprecated in 4.5.0. [[\craft\services\Structures::EVENT_BEFORE_INSERT_ELEMENT]],
16-
* [[\craft\services\Structures::EVENT_AFTER_INSERT_ELEMENT|EVENT_AFTER_INSERT_ELEMENT]],
17-
* [[\craft\services\Structures::EVENT_BEFORE_MOVE_ELEMENT|EVENT_BEFORE_MOVE_ELEMENT]] and
18-
* [[\craft\services\Structures::EVENT_AFTER_MOVE_ELEMENT|EVENT_AFTER_MOVE_ELEMENT]] should be used instead.
1915
*/
2016
class ElementStructureEvent extends ModelEvent
2117
{

src/services/Structures.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,35 @@ class Structures extends Component
4848
*/
4949
public const EVENT_AFTER_INSERT_ELEMENT = 'afterInsertElement';
5050

51+
/**
52+
* @event MoveElementEvent The event that is triggered before an element’s position is updated.
53+
*
54+
* You may set [[\yii\base\ModelEvent::$isValid]] to `false` to prevent the element from getting repositioned.
55+
*
56+
* @since 5.9.0
57+
*/
58+
public const EVENT_BEFORE_UPDATE_ELEMENT = 'beforeMoveElement';
59+
60+
/**
61+
* @event MoveElementEvent The event that is triggered after an element’s position is updated.
62+
* @since 5.9.0
63+
*/
64+
public const EVENT_AFTER_UPDATE_ELEMENT = 'afterMoveElement';
65+
5166
/**
5267
* @event MoveElementEvent The event that is triggered before an element is moved.
5368
*
5469
* In Craft 4.5 and later, you may set [[\yii\base\ModelEvent::$isValid]] to `false` to prevent the
5570
* element from getting moved.
71+
*
72+
* @deprecated in 5.9.0. [[EVENT_BEFORE_UPDATE_ELEMENT]] should be used instead.
5673
*/
5774
public const EVENT_BEFORE_MOVE_ELEMENT = 'beforeMoveElement';
5875

5976
/**
6077
* @event MoveElementEvent The event that is triggered after an element is moved.
78+
*
79+
* @deprecated in 5.9.0. [[EVENT_AFTER_UPDATE_ELEMENT]] should be used instead.
6180
*/
6281
public const EVENT_AFTER_MOVE_ELEMENT = 'afterMoveElement';
6382

@@ -540,7 +559,7 @@ private function _doIt(int $structureId, ElementInterface $element, StructureEle
540559

541560
[$beforeEvent, $afterEvent] = match ($mode) {
542561
self::MODE_INSERT => [self::EVENT_BEFORE_INSERT_ELEMENT, self::EVENT_AFTER_INSERT_ELEMENT],
543-
self::MODE_UPDATE => [self::EVENT_BEFORE_MOVE_ELEMENT, self::EVENT_AFTER_MOVE_ELEMENT],
562+
self::MODE_UPDATE => [self::EVENT_BEFORE_UPDATE_ELEMENT, self::EVENT_AFTER_UPDATE_ELEMENT],
544563
};
545564

546565
$targetElementId = $targetElementRecord->isRoot() ? null : $targetElementRecord->elementId;

0 commit comments

Comments
 (0)