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