ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
31  public function __construct(
32  private int $object_id,
33  private int $calling_id,
34  private int $context
35  ) {
36  // $context mut be one of the constants
37  if ($context !== self::CONTEXT_REPO && $context !== self::CONTEXT_WORKSPACE) {
38  throw new \InvalidArgumentException('Invalid context');
39  }
40  }
41 
42  public function getObjectId(): int
43  {
44  return $this->object_id;
45  }
46 
47  public function getCallingId(): int
48  {
49  return $this->calling_id;
50  }
51 
52  public function getContext(): int
53  {
54  return $this->context;
55  }
56 
57  public function getNode(): string
58  {
59  return $this->getContext() . '_' . $this->getCallingId();
60  }
61 
62  public function withCallingId(int $calling_id): self
63  {
64  $clone = clone $this;
65  $clone->calling_id = $calling_id;
66  return $clone;
67  }
68 
69  public function withObjectId(int $object_id): self
70  {
71  $clone = clone $this;
72  $clone->object_id = $object_id;
73  return $clone;
74  }
75 
76  public function __toString(): string
77  {
78  return (string) $this->getCallingId();
79  }
80 
81 }
$context
Definition: webdav.php:31
withObjectId(int $object_id)
Definition: Context.php:69
withCallingId(int $calling_id)
Definition: Context.php:62
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:31