ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Infos.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
28class Infos implements InfosInterface
29{
30 protected ControlledRepo $controlled_repo;
31 protected StandardRepo $standard_repo;
32
33 public function __construct(
34 ControlledRepo $controlled_repo,
35 StandardRepo $standard_repo
36 ) {
37 $this->controlled_repo = $controlled_repo;
38 $this->standard_repo = $standard_repo;
39 }
40
41 public function isDeactivatable(VocabularyInterface $vocabulary): bool
42 {
43 switch ($vocabulary->type()) {
44 case Type::STANDARD:
45 case Type::CONTROLLED_VOCAB_VALUE:
46 return $this->hasSlotOfVocabularyAnotherActiveVocabulary($vocabulary);
47
48 case Type::CONTROLLED_STRING:
49 return true;
50
51 default:
52 case Type::COPYRIGHT:
53 return false;
54 }
55 }
56
57 public function canDisallowCustomInput(VocabularyInterface $vocabulary): bool
58 {
59 switch ($vocabulary->type()) {
60 case Type::CONTROLLED_STRING:
61 return true;
62
63 default:
64 case Type::CONTROLLED_VOCAB_VALUE:
65 case Type::STANDARD:
66 case Type::COPYRIGHT:
67 return false;
68 }
69 }
70
71 public function isCustomInputApplicable(VocabularyInterface $vocabulary): bool
72 {
73 switch ($vocabulary->type()) {
74 case Type::CONTROLLED_STRING:
75 case Type::COPYRIGHT:
76 return true;
77
78 default:
79 case Type::CONTROLLED_VOCAB_VALUE:
80 case Type::STANDARD:
81 return false;
82 }
83 }
84
85 public function canBeDeleted(VocabularyInterface $vocabulary): bool
86 {
87 switch ($vocabulary->type()) {
88 case Type::CONTROLLED_STRING:
89 return true;
90
91 case Type::CONTROLLED_VOCAB_VALUE:
92 return $this->hasSlotOfVocabularyAnotherActiveVocabulary($vocabulary);
93
94 default:
95 case Type::STANDARD:
96 case Type::COPYRIGHT:
97 return false;
98 }
99 }
100
105 {
106 $slot = $vocabulary->slot();
107 $other_active_repositories_count =
108 ((int) $this->standard_repo->isVocabularyActive($slot)) +
109 $this->controlled_repo->countActiveVocabulariesForSlot($slot) -
110 ((int) $vocabulary->isActive());
111 return $other_active_repositories_count > 0;
112 }
113}
isCustomInputApplicable(VocabularyInterface $vocabulary)
Definition: Infos.php:71
canDisallowCustomInput(VocabularyInterface $vocabulary)
Definition: Infos.php:57
hasSlotOfVocabularyAnotherActiveVocabulary(VocabularyInterface $vocabulary)
Whether the given vocabulary is active or not is irrelevant.
Definition: Infos.php:104
canBeDeleted(VocabularyInterface $vocabulary)
Definition: Infos.php:85
__construct(ControlledRepo $controlled_repo, StandardRepo $standard_repo)
Definition: Infos.php:33
isDeactivatable(VocabularyInterface $vocabulary)
Definition: Infos.php:41