b176c4dafca9c9f59da2590080d5f11b3818b491
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\object\type;
3 use wcf\data\object\type\AbstractObjectTypeProcessor;
4 use wcf\data\DatabaseObjectList;
5
6 /**
7 * Provides a default implementation of IUserNotificationObjectType.
8 *
9 * @author Marcel Werk
10 * @copyright 2001-2018 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package WoltLabSuite\Core\System\User\Notification\Object\Type
13 */
14 class AbstractUserNotificationObjectType extends AbstractObjectTypeProcessor implements IUserNotificationObjectType {
15 /**
16 * class name of the object decorator
17 * @var string
18 */
19 protected static $decoratorClassName = '';
20
21 /**
22 * object class name
23 * @var string
24 */
25 protected static $objectClassName = '';
26
27 /**
28 * class name for DatabaseObjectList
29 * @var string
30 */
31 protected static $objectListClassName = '';
32
33 /**
34 * @inheritDoc
35 */
36 public function getObjectsByIDs(array $objectIDs) {
37 $indexName = call_user_func([static::$objectClassName, 'getDatabaseTableIndexName']);
38
39 /** @var DatabaseObjectList $objectList */
40 $objectList = new static::$objectListClassName();
41 $objectList->setObjectIDs($objectIDs);
42 $objectList->sqlLimit = 0;
43 $objectList->decoratorClassName = static::$decoratorClassName;
44 $objectList->readObjects();
45 $objects = $objectList->getObjects();
46
47 foreach ($objectIDs as $objectID) {
48 // append empty objects for unknown ids
49 if (!isset($objects[$objectID])) {
50 // '__unknownNotificationObject' tells the notification API
51 // that the object does not exist anymore so that the related
52 // notification can be deleted automatically
53 $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, [
54 '__unknownNotificationObject' => true,
55 $indexName => $objectID
56 ]));
57 }
58 }
59
60 return $objects;
61 }
62 }