From 5b5f29a27e07270ac8b2918164e36c995f1ef734 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Mon, 7 Aug 2023 10:16:00 +0200 Subject: [PATCH] make removeChild and removeBlock as NEXT_MAJOR --- src/Model/PageInterface.php | 15 +++++++++++++-- src/Model/SnapshotPageProxy.php | 10 ++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Model/PageInterface.php b/src/Model/PageInterface.php index 3674e2d9a..c502d59b3 100644 --- a/src/Model/PageInterface.php +++ b/src/Model/PageInterface.php @@ -17,6 +17,11 @@ /** * @author Thomas Rabaix + * + * NEXT_MAJOR: add these methods + * + * @method removeChild(PageInterface $child) + * @method removeBlock(PageBlockInterface $block) */ interface PageInterface extends \Stringable { @@ -113,7 +118,10 @@ public function setChildren(Collection $children): void; public function addChild(self $child): void; - public function removeChild(self $child): void; + /** + * NEXT_MAJOR uncomment this. + */ + // public function removeChild(self $child): void; /** * @return Collection @@ -122,7 +130,10 @@ public function getBlocks(): Collection; public function addBlock(PageBlockInterface $block): void; - public function removeBlock(PageBlockInterface $block): void; + /** + * NEXT_MAJOR uncomment this. + */ + // public function removeBlock(PageBlockInterface $block): void; public function getContainerByCode(string $code): ?PageBlockInterface; diff --git a/src/Model/SnapshotPageProxy.php b/src/Model/SnapshotPageProxy.php index 74930b019..b8dc38ec7 100644 --- a/src/Model/SnapshotPageProxy.php +++ b/src/Model/SnapshotPageProxy.php @@ -258,7 +258,10 @@ public function addChild(PageInterface $child): void public function removeChild(PageInterface $child): void { - $this->getPage()->removeChild($child); + // NEXT_MAJOR remove check + if (method_exists($this->getPage(), 'removeChild')) { + $this->getPage()->removeChild($child); + } } public function getBlocks(): Collection @@ -286,7 +289,10 @@ public function addBlock(PageBlockInterface $block): void public function removeBlock(PageBlockInterface $block): void { - $this->getPage()->removeBlock($block); + // NEXT_MAJOR remove check + if (method_exists($this->getPage(), 'removeBlock')) { + $this->getPage()->removeBlock($block); + } } public function getContainerByCode(string $code): ?PageBlockInterface