4d8662ac6e14f1bad19fa2e17e6c5790843a33a5
[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-2016 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage system.user.notification.object.type
14 * @category Community Framework
15 */
16 class AbstractUserNotificationObjectType extends AbstractObjectTypeProcessor implements IUserNotificationObjectType {
17 /**
18 * class name of the object decorator
19 * @var string
20 */
21 protected static $decoratorClassName = '';
22
23 /**
24 * object class name
25 * @var string
26 */
27 protected static $objectClassName = '';
28
29 /**
30 * class name for DatabaseObjectList
31 * @var string
32 */
33 protected static $objectListClassName = '';
34
35 /**
36 * @inheritDoc
37 */
38 public function getObjectsByIDs(array $objectIDs) {
39 $indexName = call_user_func([static::$objectClassName, 'getDatabaseTableIndexName']);
40
41 /** @var DatabaseObjectList $objectList */
42 $objectList = new static::$objectListClassName();
43 $objectList->setObjectIDs($objectIDs);
44 $objectList->sqlLimit = 0;
45 $objectList->decoratorClassName = static::$decoratorClassName;
46 $objectList->readObjects();
47 $objects = $objectList->getObjects();
48
49 foreach ($objectIDs as $objectID) {
50 // append empty objects for unknown ids
51 if (!isset($objects[$objectID])) {
52 // '__unknownNotificationObject' tells the notification API
53 // that the object does not exist anymore so that the related
54 // notification can be deleted automatically
55 $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, [
56 '__unknownNotificationObject' => true,
57 $indexName => $objectID
58 ]));
59 }
60 }
61
62 return $objects;
63 }
64 }