Skip to content

Commit 2e094d2

Browse files
committed
Merge branch '6.1' of https://github.com/WoltLab/docs.woltlab.com into 6.1
2 parents 65e241a + bfd5e39 commit 2e094d2

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/migration/wsc60/php.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,55 @@ class FooBarCategoryEditForm extends FooBarCategoryAddForm {
146146

147147
See [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

Comments
 (0)