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