@@ -146,3 +146,55 @@ class FooBarCategoryEditForm extends FooBarCategoryAddForm {
146146
147147See [ WoltLab/WCF #5657 ] (https://github.com/WoltLab/WCF/pull/5657
148148) for more details.
149+
150+ ## Loading embedded objects for quotes
151+
152+ When saving a quote, it is necessary to load embedded objects before adding the quote to the ` MessageQuoteManager ` .
153+ This is to ensure that the embedded objects are displayed correctly in the quote preview.
154+
155+ ``` PHP
156+ public class FooBarAction extends AbstractDatabaseObjectAction implements IMessageQuoteAction
157+ {
158+ private function loadEmbeddedObjects(): void
159+ {
160+ if ($this->object->hasEmbeddedObjects) {
161+ ObjectTypeCache::getInstance()
162+ ->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'foo.bar.attachment')
163+ ->getProcessor()
164+ ->cacheObjects([$this->object->objectID]);
165+ MessageEmbeddedObjectManager::getInstance()->loadObjects(
166+ 'foo.bar.message',
167+ [$this->object->objectID]
168+ );
169+ }
170+ }
171+
172+ public function saveFullQuote()
173+ {
174+ $this->loadEmbeddedObjects();
175+
176+ $quoteID = MessageQuoteManager::getInstance()->addQuote(
177+ 'foo.bar.message',
178+ $this->object->parentObjectID,
179+ $this->object->objectID,
180+ $this->object->getExcerpt(),
181+ $this->object->getMessage()
182+ );
183+ …
184+ }
185+
186+ public function saveQuote()
187+ {
188+ $this->loadEmbeddedObjects();
189+
190+ $quoteID = MessageQuoteManager::getInstance()->addQuote(
191+ 'foo.bar.message',
192+ $this->object->parentObjectID,
193+ $this->object->objectID,
194+ $this->parameters['message'],
195+ false
196+ );
197+ …
198+ }
199+ }
200+ ```
0 commit comments