From 949d78a586a7b28e3072f552919687727bcab4d7 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Tue, 17 Oct 2023 09:15:13 +0200 Subject: [PATCH 1/9] feat: added before load event for objects, documents and assets --- lib/Event/AssetEvents.php | 10 ++++ lib/Event/DataObjectEvents.php | 10 ++++ lib/Event/DocumentEvents.php | 10 ++++ lib/Event/Model/AssetPreLoadEvent.php | 58 ++++++++++++++++++++++ lib/Event/Model/DataObjectPreLoadEvent.php | 57 +++++++++++++++++++++ lib/Event/Model/DocumentPreLoadEvent.php | 57 +++++++++++++++++++++ models/Asset.php | 7 +++ models/DataObject/AbstractObject.php | 6 +++ models/Document.php | 5 ++ 9 files changed, 220 insertions(+) create mode 100644 lib/Event/Model/AssetPreLoadEvent.php create mode 100644 lib/Event/Model/DataObjectPreLoadEvent.php create mode 100644 lib/Event/Model/DocumentPreLoadEvent.php diff --git a/lib/Event/AssetEvents.php b/lib/Event/AssetEvents.php index 4142790cef7..9ad64baddb7 100644 --- a/lib/Event/AssetEvents.php +++ b/lib/Event/AssetEvents.php @@ -115,6 +115,16 @@ final class AssetEvents */ const POST_DELETE_FAILURE = 'pimcore.asset.postDeleteFailure'; + /** + * Arguments: + * - params | array | contains the values that were passed to getById() as the second parameter + * + * @Event("Pimcore\Event\Model\AssetPreLoadEvent") + * + * @var string + */ + const PRE_LOAD = 'pimcore.asset.preLoad'; + /** * Arguments: * - params | array | contains the values that were passed to getById() as the second parameter diff --git a/lib/Event/DataObjectEvents.php b/lib/Event/DataObjectEvents.php index ce80fa31628..a5b749c2193 100644 --- a/lib/Event/DataObjectEvents.php +++ b/lib/Event/DataObjectEvents.php @@ -117,6 +117,16 @@ final class DataObjectEvents */ const POST_DELETE_FAILURE = 'pimcore.dataobject.postDeleteFailure'; + /** + * Arguments: + * - params | array | contains the values that were passed to getById() as the second parameter + * + * @Event("Pimcore\Event\Model\DataObjectPreLoadEvent") + * + * @var string + */ + const PRE_LOAD = 'pimcore.dataobject.preLoad'; + /** * Arguments: * - params | array | contains the values that were passed to getById() as the second parameter diff --git a/lib/Event/DocumentEvents.php b/lib/Event/DocumentEvents.php index a68780de7af..e88aff5893b 100644 --- a/lib/Event/DocumentEvents.php +++ b/lib/Event/DocumentEvents.php @@ -105,6 +105,16 @@ final class DocumentEvents */ const POST_DELETE_FAILURE = 'pimcore.document.postDeleteFailure'; + /** + * Arguments: + * - params | array | contains the values that were passed to getById() as the second parameter + * + * @Event("Pimcore\Event\Model\DocumentPreLoadEvent") + * + * @var string + */ + const PRE_LOAD = 'pimcore.document.preLoad'; + /** * Arguments: * - params | array | contains the values that were passed to getById() as the second parameter diff --git a/lib/Event/Model/AssetPreLoadEvent.php b/lib/Event/Model/AssetPreLoadEvent.php new file mode 100644 index 00000000000..b9e2c0ecbca --- /dev/null +++ b/lib/Event/Model/AssetPreLoadEvent.php @@ -0,0 +1,58 @@ +asset = $asset; + $this->arguments = $arguments; + } + + public function getAsset(): ?Asset + { + if (empty($this->document)) { + throw new NotFoundException(); + } + return $this->asset; + } + + public function setAsset(?Asset $asset): void + { + $this->asset = $asset; + } + + public function getElement(): Asset + { + return $this->getAsset(); + } +} diff --git a/lib/Event/Model/DataObjectPreLoadEvent.php b/lib/Event/Model/DataObjectPreLoadEvent.php new file mode 100644 index 00000000000..376939275a1 --- /dev/null +++ b/lib/Event/Model/DataObjectPreLoadEvent.php @@ -0,0 +1,57 @@ +object = $object; + $this->arguments = $arguments; + } + + public function getObject(): ?AbstractObject + { + if (empty($this->object)) { + throw new NotFoundException(); + } + return $this->object; + } + + public function setObject(?AbstractObject $object): void + { + $this->object = $object; + } + + public function getElement(): AbstractObject + { + return $this->getObject(); + } +} diff --git a/lib/Event/Model/DocumentPreLoadEvent.php b/lib/Event/Model/DocumentPreLoadEvent.php new file mode 100644 index 00000000000..71b8676b1bc --- /dev/null +++ b/lib/Event/Model/DocumentPreLoadEvent.php @@ -0,0 +1,57 @@ +document = $document; + $this->arguments = $arguments; + } + + public function getDocument(): ?Document + { + if (empty($this->document)) { + throw new NotFoundException(); + } + return $this->document; + } + + public function setDocument(?Document $document): void + { + $this->document = $document; + } + + public function getElement(): Document + { + return $this->getDocument(); + } +} diff --git a/models/Asset.php b/models/Asset.php index 44a9f33a3a1..4184bc08cf3 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -17,6 +17,8 @@ use Doctrine\DBAL\Exception\DeadlockException; use Exception; +use Pimcore\Event\DocumentEvents; +use Pimcore\Event\Model\DocumentPreLoadEvent; use function is_array; use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; @@ -29,6 +31,7 @@ use Pimcore\Event\AssetEvents; use Pimcore\Event\FrontendEvents; use Pimcore\Event\Model\AssetEvent; +use Pimcore\Event\Model\AssetPreLoadEvent; use Pimcore\File; use Pimcore\Helper\TemporaryFileHelperTrait; use Pimcore\Loader\ImplementationLoader\Exception\UnsupportedException; @@ -247,6 +250,10 @@ public static function getById(int|string $id, array $params = []): ?static try { $asset->getDao()->getById($id); + // fire pre load event + $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); + $asset = $preLoadEvent->getAsset(); $className = \Pimcore::getContainer()->get('pimcore.class.resolver.asset')->resolve($asset->getType()); /** @var Asset $newAsset */ diff --git a/models/DataObject/AbstractObject.php b/models/DataObject/AbstractObject.php index 9f9781a529d..a4a04396f1e 100644 --- a/models/DataObject/AbstractObject.php +++ b/models/DataObject/AbstractObject.php @@ -23,6 +23,7 @@ use Pimcore\Db; use Pimcore\Event\DataObjectEvents; use Pimcore\Event\Model\DataObjectEvent; +use Pimcore\Event\Model\DataObjectPreLoadEvent; use Pimcore\Logger; use Pimcore\Model; use Pimcore\Model\DataObject; @@ -242,6 +243,11 @@ public static function getById(int|string $id, array $params = []): ?static $object = self::getModelFactory()->build($className); RuntimeCache::set($cacheKey, $object); $object->getDao()->getById($id); + // fire pre load event + $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); + $object = $preLoadEvent->getObject(); + $object->__setDataVersionTimestamp($object->getModificationDate()); Service::recursiveResetDirtyMap($object); diff --git a/models/Document.php b/models/Document.php index 4e2e0c976f0..770e4dd04d5 100644 --- a/models/Document.php +++ b/models/Document.php @@ -21,6 +21,7 @@ use Pimcore\Event\DocumentEvents; use Pimcore\Event\FrontendEvents; use Pimcore\Event\Model\DocumentEvent; +use Pimcore\Event\Model\DocumentPreLoadEvent; use Pimcore\Logger; use Pimcore\Model\Document\Hardlink\Wrapper\WrapperInterface; use Pimcore\Model\Document\Listing; @@ -211,6 +212,10 @@ public static function getById(int|string $id, array $params = []): ?static try { $document->getDao()->getById($id); + // fire pre load event + $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); + $document = $preLoadEvent->getDocument(); } catch (NotFoundException $e) { return null; } From d37eeb9f4bcab8afee964c1dfaa130915f60de91 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Tue, 17 Oct 2023 10:52:31 +0200 Subject: [PATCH 2/9] fix: fixed asset event --- lib/Event/Model/AssetPreLoadEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Event/Model/AssetPreLoadEvent.php b/lib/Event/Model/AssetPreLoadEvent.php index b9e2c0ecbca..4039d8bad3d 100644 --- a/lib/Event/Model/AssetPreLoadEvent.php +++ b/lib/Event/Model/AssetPreLoadEvent.php @@ -40,7 +40,7 @@ public function __construct(?Asset $asset, array $arguments = []) public function getAsset(): ?Asset { - if (empty($this->document)) { + if (empty($this->asset)) { throw new NotFoundException(); } return $this->asset; From 967f9d049943fc29ad1f5aec6dbf79894e79cc23 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Tue, 17 Oct 2023 10:55:40 +0200 Subject: [PATCH 3/9] fix: fixed types on getter methods --- lib/Event/Model/AssetPreLoadEvent.php | 2 +- lib/Event/Model/DataObjectPreLoadEvent.php | 2 +- lib/Event/Model/DocumentPreLoadEvent.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Event/Model/AssetPreLoadEvent.php b/lib/Event/Model/AssetPreLoadEvent.php index 4039d8bad3d..7bc9a272a98 100644 --- a/lib/Event/Model/AssetPreLoadEvent.php +++ b/lib/Event/Model/AssetPreLoadEvent.php @@ -38,7 +38,7 @@ public function __construct(?Asset $asset, array $arguments = []) $this->arguments = $arguments; } - public function getAsset(): ?Asset + public function getAsset(): Asset { if (empty($this->asset)) { throw new NotFoundException(); diff --git a/lib/Event/Model/DataObjectPreLoadEvent.php b/lib/Event/Model/DataObjectPreLoadEvent.php index 376939275a1..153537d5b2f 100644 --- a/lib/Event/Model/DataObjectPreLoadEvent.php +++ b/lib/Event/Model/DataObjectPreLoadEvent.php @@ -37,7 +37,7 @@ public function __construct(?AbstractObject $object, array $arguments = []) $this->arguments = $arguments; } - public function getObject(): ?AbstractObject + public function getObject(): AbstractObject { if (empty($this->object)) { throw new NotFoundException(); diff --git a/lib/Event/Model/DocumentPreLoadEvent.php b/lib/Event/Model/DocumentPreLoadEvent.php index 71b8676b1bc..2553f3a2cbc 100644 --- a/lib/Event/Model/DocumentPreLoadEvent.php +++ b/lib/Event/Model/DocumentPreLoadEvent.php @@ -37,7 +37,7 @@ public function __construct(?Document $document, array $arguments = []) $this->arguments = $arguments; } - public function getDocument(): ?Document + public function getDocument(): Document { if (empty($this->document)) { throw new NotFoundException(); From 420d2c87f8cb76ff8276869aedac484f56ce15a7 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Tue, 17 Oct 2023 11:06:48 +0200 Subject: [PATCH 4/9] chore: do null check instead of empty --- lib/Event/Model/AssetPreLoadEvent.php | 4 ++-- lib/Event/Model/DataObjectPreLoadEvent.php | 4 ++-- lib/Event/Model/DocumentPreLoadEvent.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Event/Model/AssetPreLoadEvent.php b/lib/Event/Model/AssetPreLoadEvent.php index 7bc9a272a98..7b6be0129c5 100644 --- a/lib/Event/Model/AssetPreLoadEvent.php +++ b/lib/Event/Model/AssetPreLoadEvent.php @@ -25,7 +25,7 @@ class AssetPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?Asset $asset; + protected ?Asset $asset = null; /** * AssetEvent constructor. @@ -40,7 +40,7 @@ public function __construct(?Asset $asset, array $arguments = []) public function getAsset(): Asset { - if (empty($this->asset)) { + if ($this->asset === null) { throw new NotFoundException(); } return $this->asset; diff --git a/lib/Event/Model/DataObjectPreLoadEvent.php b/lib/Event/Model/DataObjectPreLoadEvent.php index 153537d5b2f..9ca316850f8 100644 --- a/lib/Event/Model/DataObjectPreLoadEvent.php +++ b/lib/Event/Model/DataObjectPreLoadEvent.php @@ -25,7 +25,7 @@ class DataObjectPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?AbstractObject $object; + protected ?AbstractObject $object = null; /** * DataObjectEvent constructor. @@ -39,7 +39,7 @@ public function __construct(?AbstractObject $object, array $arguments = []) public function getObject(): AbstractObject { - if (empty($this->object)) { + if ($this->object === null) { throw new NotFoundException(); } return $this->object; diff --git a/lib/Event/Model/DocumentPreLoadEvent.php b/lib/Event/Model/DocumentPreLoadEvent.php index 2553f3a2cbc..c57becc6690 100644 --- a/lib/Event/Model/DocumentPreLoadEvent.php +++ b/lib/Event/Model/DocumentPreLoadEvent.php @@ -25,7 +25,7 @@ class DocumentPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?Document $document; + protected ?Document $document = null; /** * DocumentEvent constructor. @@ -39,7 +39,7 @@ public function __construct(?Document $document, array $arguments = []) public function getDocument(): Document { - if (empty($this->document)) { + if ($this->document === null) { throw new NotFoundException(); } return $this->document; From 96c4f8cc7b9798b501f218326abcf791428a1361 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Tue, 17 Oct 2023 11:45:05 +0200 Subject: [PATCH 5/9] chore: remove null assignment --- lib/Event/Model/AssetPreLoadEvent.php | 2 +- lib/Event/Model/DataObjectPreLoadEvent.php | 2 +- lib/Event/Model/DocumentPreLoadEvent.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Event/Model/AssetPreLoadEvent.php b/lib/Event/Model/AssetPreLoadEvent.php index 7b6be0129c5..62d0cda958b 100644 --- a/lib/Event/Model/AssetPreLoadEvent.php +++ b/lib/Event/Model/AssetPreLoadEvent.php @@ -25,7 +25,7 @@ class AssetPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?Asset $asset = null; + protected ?Asset $asset; /** * AssetEvent constructor. diff --git a/lib/Event/Model/DataObjectPreLoadEvent.php b/lib/Event/Model/DataObjectPreLoadEvent.php index 9ca316850f8..56633f858af 100644 --- a/lib/Event/Model/DataObjectPreLoadEvent.php +++ b/lib/Event/Model/DataObjectPreLoadEvent.php @@ -25,7 +25,7 @@ class DataObjectPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?AbstractObject $object = null; + protected ?AbstractObject $object; /** * DataObjectEvent constructor. diff --git a/lib/Event/Model/DocumentPreLoadEvent.php b/lib/Event/Model/DocumentPreLoadEvent.php index c57becc6690..8a719f69ee7 100644 --- a/lib/Event/Model/DocumentPreLoadEvent.php +++ b/lib/Event/Model/DocumentPreLoadEvent.php @@ -25,7 +25,7 @@ class DocumentPreLoadEvent extends Event implements ElementEventInterface { use ArgumentsAwareTrait; - protected ?Document $document = null; + protected ?Document $document; /** * DocumentEvent constructor. From 71f88c97f8a042333ddf19102f6cbdda8eecca4a Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Wed, 18 Oct 2023 17:04:39 +0200 Subject: [PATCH 6/9] feat: fire event on cached entries --- models/Asset.php | 10 ++++++++-- models/DataObject/AbstractObject.php | 8 ++++++++ models/Document.php | 8 ++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/models/Asset.php b/models/Asset.php index d284e61ac0f..b42d002f89b 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -17,8 +17,6 @@ use Doctrine\DBAL\Exception\DeadlockException; use Exception; -use Pimcore\Event\DocumentEvents; -use Pimcore\Event\Model\DocumentPreLoadEvent; use function is_array; use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; @@ -274,6 +272,14 @@ public static function getById(int|string $id, array $params = []): ?static $asset = null; } } else { + try { + // fire pre load event + $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); + $asset = $preLoadEvent->getAsset(); + } catch (NotFoundException $e) { + return null; + } RuntimeCache::set($cacheKey, $asset); } diff --git a/models/DataObject/AbstractObject.php b/models/DataObject/AbstractObject.php index a4a04396f1e..1d6e4c877cd 100644 --- a/models/DataObject/AbstractObject.php +++ b/models/DataObject/AbstractObject.php @@ -267,6 +267,14 @@ public static function getById(int|string $id, array $params = []): ?static return null; } } else { + try { + // fire pre load event + $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); + $object = $preLoadEvent->getObject(); + } catch (Model\Exception\NotFoundException $e) { + return null; + } RuntimeCache::set($cacheKey, $object); } diff --git a/models/Document.php b/models/Document.php index 770e4dd04d5..bcc7c4c1bd2 100644 --- a/models/Document.php +++ b/models/Document.php @@ -240,6 +240,14 @@ public static function getById(int|string $id, array $params = []): ?static \Pimcore\Cache::save($document, $cacheKey); } else { + try { + // fire pre load event + $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); + \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); + $document = $preLoadEvent->getDocument(); + } catch (NotFoundException $e) { + return null; + } RuntimeCache::set($cacheKey, $document); } From 8873bad2afa4a182826bad9d3e2c9855a274d2ec Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Thu, 19 Oct 2023 08:35:58 +0200 Subject: [PATCH 7/9] chore: fix php stan error --- models/Asset.php | 1 + models/DataObject/AbstractObject.php | 1 + models/Document.php | 1 + 3 files changed, 3 insertions(+) diff --git a/models/Asset.php b/models/Asset.php index b42d002f89b..5f8b65e9eed 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -276,6 +276,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); + /** @var ?static $asset */ $asset = $preLoadEvent->getAsset(); } catch (NotFoundException $e) { return null; diff --git a/models/DataObject/AbstractObject.php b/models/DataObject/AbstractObject.php index 1d6e4c877cd..980d9b995c3 100644 --- a/models/DataObject/AbstractObject.php +++ b/models/DataObject/AbstractObject.php @@ -271,6 +271,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); + /** @var ?static $object */ $object = $preLoadEvent->getObject(); } catch (Model\Exception\NotFoundException $e) { return null; diff --git a/models/Document.php b/models/Document.php index bcc7c4c1bd2..6c89906a2cc 100644 --- a/models/Document.php +++ b/models/Document.php @@ -244,6 +244,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); + /** @var ?static $document */ $document = $preLoadEvent->getDocument(); } catch (NotFoundException $e) { return null; From 3745b9121dbbbea6b7954ec9a387029830554945 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Thu, 19 Oct 2023 08:43:17 +0200 Subject: [PATCH 8/9] chore: fix php stan error --- models/Asset.php | 1 + models/DataObject/AbstractObject.php | 1 + models/Document.php | 1 + 3 files changed, 3 insertions(+) diff --git a/models/Asset.php b/models/Asset.php index 5f8b65e9eed..2a320be3299 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -251,6 +251,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); + /** @var ?static $asset */ $asset = $preLoadEvent->getAsset(); $className = \Pimcore::getContainer()->get('pimcore.class.resolver.asset')->resolve($asset->getType()); diff --git a/models/DataObject/AbstractObject.php b/models/DataObject/AbstractObject.php index 980d9b995c3..22597c0ca67 100644 --- a/models/DataObject/AbstractObject.php +++ b/models/DataObject/AbstractObject.php @@ -246,6 +246,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); + /** @var ?static $object */ $object = $preLoadEvent->getObject(); $object->__setDataVersionTimestamp($object->getModificationDate()); diff --git a/models/Document.php b/models/Document.php index 6c89906a2cc..f279fdb44d7 100644 --- a/models/Document.php +++ b/models/Document.php @@ -215,6 +215,7 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); + /** @var ?static $document */ $document = $preLoadEvent->getDocument(); } catch (NotFoundException $e) { return null; From 83348ea8cea5a42e9116a94f16e935701537a7b9 Mon Sep 17 00:00:00 2001 From: Stefan Scheu Date: Thu, 19 Oct 2023 08:51:30 +0200 Subject: [PATCH 9/9] chore: another try to fix php stan issue --- models/Asset.php | 4 +--- models/DataObject/AbstractObject.php | 4 +--- models/Document.php | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/models/Asset.php b/models/Asset.php index 2a320be3299..c7645db3b8a 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -251,7 +251,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); - /** @var ?static $asset */ $asset = $preLoadEvent->getAsset(); $className = \Pimcore::getContainer()->get('pimcore.class.resolver.asset')->resolve($asset->getType()); @@ -277,7 +276,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new AssetPreLoadEvent($asset, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, AssetEvents::PRE_LOAD); - /** @var ?static $asset */ $asset = $preLoadEvent->getAsset(); } catch (NotFoundException $e) { return null; @@ -293,7 +291,7 @@ public static function getById(int|string $id, array $params = []): ?static } else { $asset = null; } - + /** @var ?static $asset */ return $asset; } diff --git a/models/DataObject/AbstractObject.php b/models/DataObject/AbstractObject.php index 22597c0ca67..efa4cd2a5b3 100644 --- a/models/DataObject/AbstractObject.php +++ b/models/DataObject/AbstractObject.php @@ -246,7 +246,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); - /** @var ?static $object */ $object = $preLoadEvent->getObject(); $object->__setDataVersionTimestamp($object->getModificationDate()); @@ -272,7 +271,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DataObjectPreLoadEvent($object, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DataObjectEvents::PRE_LOAD); - /** @var ?static $object */ $object = $preLoadEvent->getObject(); } catch (Model\Exception\NotFoundException $e) { return null; @@ -288,7 +286,7 @@ public static function getById(int|string $id, array $params = []): ?static new DataObjectEvent($object, ['params' => $params]), DataObjectEvents::POST_LOAD ); - + /** @var ?static $object */ return $object; } diff --git a/models/Document.php b/models/Document.php index f279fdb44d7..791a1053918 100644 --- a/models/Document.php +++ b/models/Document.php @@ -215,7 +215,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); - /** @var ?static $document */ $document = $preLoadEvent->getDocument(); } catch (NotFoundException $e) { return null; @@ -245,7 +244,6 @@ public static function getById(int|string $id, array $params = []): ?static // fire pre load event $preLoadEvent = new DocumentPreLoadEvent($document, ['params' => $params]); \Pimcore::getEventDispatcher()->dispatch($preLoadEvent, DocumentEvents::PRE_LOAD); - /** @var ?static $document */ $document = $preLoadEvent->getDocument(); } catch (NotFoundException $e) { return null; @@ -261,7 +259,7 @@ public static function getById(int|string $id, array $params = []): ?static new DocumentEvent($document, ['params' => $params]), DocumentEvents::POST_LOAD ); - + /** @var ?static $document */ return $document; }