ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ResourceCollection.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
33 {
34  public const NO_SPECIFIC_OWNER = -1;
35  private array $resource_identifications = [];
39  private string $title = 'default';
40  private ResourceCollectionIdentification $identification;
41  private int $owner;
42 
43  public function __construct(
44  ResourceCollectionIdentification $identification,
45  int $owner,
46  string $title // currently unused
47  ) {
48  $this->identification = $identification;
49  $this->owner = $owner;
50  }
51 
52  public function getIdentification(): ResourceCollectionIdentification
53  {
54  return $this->identification;
55  }
56 
57  public function hasSpecificOwner(): bool
58  {
59  return $this->owner !== self::NO_SPECIFIC_OWNER;
60  }
61 
62  public function getOwner(): int
63  {
64  return $this->owner;
65  }
66 
67  public function getTitle(): string
68  {
69  return $this->title;
70  }
71 
72  public function add(ResourceIdentification $identification): void
73  {
74  if ($this->isIn($identification)) {
75  return;
76  }
77  $this->resource_identifications[] = $identification;
78  }
79 
80  public function remove(ResourceIdentification $identification): void
81  {
82  $this->resource_identifications = array_filter(
83  $this->resource_identifications,
84  fn(ResourceIdentification $i): bool => $i->serialize() !== $identification->serialize()
85  );
86  }
87 
88  public function isIn(ResourceIdentification $identification): bool
89  {
90  foreach ($this->resource_identifications as $i) {
91  if ($i->serialize() === $identification->serialize()) {
92  return true;
93  }
94  }
95  return false;
96  }
97 
101  public function getResourceIdentifications(): array
102  {
104  }
105 
106  public function count(): int
107  {
108  return count($this->resource_identifications);
109  }
110 
111  public function clear(): void
112  {
113  $this->resource_identifications = [];
114  }
115 }
__construct(ResourceCollectionIdentification $identification, int $owner, string $title)