3 namespace wcf\system\importer
;
5 use wcf\data\user\
object\watch\UserObjectWatch
;
6 use wcf\data\user\
object\watch\UserObjectWatchEditor
;
7 use wcf\system\database\DatabaseException
;
10 * Imports watched objects.
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\Importer
17 class AbstractWatchedObjectImporter
extends AbstractImporter
22 protected $className = UserObjectWatch
::class;
25 * object type id for watched objects
28 protected $objectTypeID = 0;
33 public function import($oldID, array $data, array $additionalData = [])
35 $data['userID'] = ImportHandler
::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
36 if (!$data['userID']) {
41 $watch = UserObjectWatchEditor
::create(\array_merge
($data, ['objectTypeID' => $this->objectTypeID
]));
43 return $watch->watchID
;
44 } catch (DatabaseException
$e) {
45 // 23000 = INTEGRITY CONSTRAINT VIOLATION a.k.a. duplicate key
46 if ($e->getCode() != 23000) {