Merge branch '3.1' into 5.2
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / system / importer / ConversationLabelImporter.class.php
1 <?php
2 namespace wcf\system\importer;
3 use wcf\data\conversation\label\ConversationLabel;
4 use wcf\data\conversation\label\ConversationLabelAction;
5
6 /**
7 * Imports conversation labels.
8 *
9 * @author Marcel Werk
10 * @copyright 2001-2019 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package WoltLabSuite\Core\System\Importer
13 */
14 class ConversationLabelImporter extends AbstractImporter {
15 /**
16 * @inheritDoc
17 */
18 protected $className = ConversationLabel::class;
19
20 /**
21 * @inheritDoc
22 */
23 public function import($oldID, array $data, array $additionalData = []) {
24 $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
25 if (!$data['userID']) return 0;
26
27 $action = new ConversationLabelAction([], 'create', [
28 'data' => $data
29 ]);
30 $returnValues = $action->executeAction();
31 $newID = $returnValues['returnValues']->labelID;
32
33 ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.conversation.label', $oldID, $newID);
34
35 return $newID;
36 }
37 }