ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Context.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\File\Capabilities;
22 
26 class Context implements \Stringable
27 {
28  public const CONTEXT_REPO = 1;
29  public const CONTEXT_WORKSPACE = 2;
30  public const CONTEXT_SEARCH = 6;
31 
32  public function __construct(
33  private int $object_id,
34  private int $calling_id,
35  private int $context
36  ) {
37  // $context mut be one of the constants
38  if ($context !== self::CONTEXT_REPO && $context !== self::CONTEXT_WORKSPACE && $context !== self::CONTEXT_SEARCH) {
39  throw new \InvalidArgumentException('Invalid context');
40  }
41  }
42 
43  public function getObjectId(): int
44  {
45  return $this->object_id;
46  }
47 
48  public function getCallingId(): int
49  {
50  return $this->calling_id;
51  }
52 
53  public function getContext(): int
54  {
55  return $this->context;
56  }
57 
58  public function getNode(): string
59  {
60  return $this->getContext() . '_' . $this->getCallingId();
61  }
62 
63  public function withCallingId(int $calling_id): self
64  {
65  $clone = clone $this;
66  $clone->calling_id = $calling_id;
67  return $clone;
68  }
69 
70  public function withObjectId(int $object_id): self
71  {
72  $clone = clone $this;
73  $clone->object_id = $object_id;
74  return $clone;
75  }
76 
77  public function __toString(): string
78  {
79  return (string) $this->getCallingId();
80  }
81 
82 }
$context
Definition: webdav.php:31
withObjectId(int $object_id)
Definition: Context.php:70
withCallingId(int $calling_id)
Definition: Context.php:63
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private int $object_id, private int $calling_id, private int $context)
Definition: Context.php:32