-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathCollectionDatabaseObject.class.php
More file actions
48 lines (42 loc) · 1.14 KB
/
CollectionDatabaseObject.class.php
File metadata and controls
48 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace wcf\data;
/**
* Abstract class for a database object that uses collections.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @template TDatabaseObjectCollection of DatabaseObjectCollection
*/
abstract class CollectionDatabaseObject extends DatabaseObject
{
/**
* @var TDatabaseObjectCollection
*/
protected DatabaseObjectCollection $collection;
/**
* @param TDatabaseObjectCollection $collection
*/
public function setCollection(DatabaseObjectCollection $collection): void
{
$this->collection = $collection;
}
/**
* @return TDatabaseObjectCollection
*/
public function getCollection(): DatabaseObjectCollection
{
if (!isset($this->collection)) {
$this->collection = new ($this->getCollectionClassName())([
$this
]);
}
return $this->collection;
}
public function getCollectionClassName(): string
{
return static::class . 'Collection';
}
}