ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TagBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\MetaData\Paths\FactoryInterface as PathFactoryInterface;
26
28{
29 protected PathFactoryInterface $path_factory;
31
32 protected ?PathInterface $representation = null;
33 protected ?PathInterface $preview = null;
34 protected ?PathInterface $created_with = null;
35 protected bool $is_collected = false;
36 protected bool $last_in_tree = false;
37 protected bool $important_label = false;
38
39 public function __construct(
40 PathFactoryInterface $path_factory,
42 ) {
43 $this->path_factory = $path_factory;
44 $this->element = $element;
45 }
46
47 public function withRepresentation(
49 ): TagBuilder {
50 $clone = clone $this;
51 $clone->representation = $this->getPath($element);
52 return $clone;
53 }
54
55 public function withPreview(
57 ): TagBuilder {
58 $clone = clone $this;
59 $clone->preview = $this->getPath($element);
60 return $clone;
61 }
62
63 public function withCreatedWith(
65 ): TagBuilder {
66 $clone = clone $this;
67 $clone->created_with = $this->getPath($element);
68 return $clone;
69 }
70
71 public function withIsCollected(bool $is_collected): TagBuilder
72 {
73 $clone = clone $this;
74 $clone->is_collected = $is_collected;
75 return $clone;
76 }
77
78 public function withLastInTree(bool $last_in_tree): TagBuilder
79 {
80 $clone = clone $this;
81 $clone->last_in_tree = $last_in_tree;
82 return $clone;
83 }
84
85 public function withImportantLabel(bool $important_label): TagBuilder
86 {
87 $clone = clone $this;
88 $clone->important_label = $important_label;
89 return $clone;
90 }
91
92 public function get(): TagInterface
93 {
94 return new Tag(
95 $this->preview,
96 $this->representation,
97 $this->created_with,
98 $this->is_collected,
99 $this->last_in_tree,
100 $this->important_label
101 );
102 }
103
104 protected function getPath(
106 ): PathInterface {
107 return $this->path_factory->betweenElements($this->element, $element);
108 }
109}
withPreview(StructureElementInterface $element)
Definition: TagBuilder.php:55
StructureElementInterface $element
Definition: TagBuilder.php:30
withImportantLabel(bool $important_label)
Definition: TagBuilder.php:85
__construct(PathFactoryInterface $path_factory, StructureElementInterface $element)
Definition: TagBuilder.php:39
withRepresentation(StructureElementInterface $element)
Definition: TagBuilder.php:47
withCreatedWith(StructureElementInterface $element)
Definition: TagBuilder.php:63
getPath(StructureElementInterface $element)
Definition: TagBuilder.php:104
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...