ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
Readable.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Modules\Test;
22 
23 use Closure;
25 use ilObject;
26 
27 class Readable
28 {
30  private $container;
32  private $references_of;
34  private $incident;
35 
36  public function __construct(
38  $references_of = [ilObject::class, '_getAllReferences'],
39  Incident $incident = null
40  ) {
41  $this->container = $container;
42  $this->references_of = Closure::fromCallable($references_of);
43  $this->incident = $incident ?? new Incident();
44  }
45 
49  public function references(array $references): bool
50  {
51  return $this->incident->any(function (int $ref_id): bool {
52  return $this->container->access()->checkAccess('read', '', $ref_id);
53  }, $references);
54  }
55 
56  public function objectId(int $obj_id): bool
57  {
58  return $this->references(array_map('intval', ($this->references_of)($obj_id)));
59  }
60 }
__construct(Container $container, $references_of=[ilObject::class, '_getAllReferences'], Incident $incident=null)
Definition: Readable.php:36
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:18
references(array $references)
Definition: Readable.php:49