ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UserCountry.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\UI\Factory as UIFactory;
29use ilObjUser;
30
31class UserCountry implements Condition
32{
33 public function __construct(
34 private readonly CriterionContent $criterion,
35 private readonly UserCountryDefinition $definition,
36 private readonly UIFactory $create
37 ) {
38 }
39
40 public function asComponent(): Component
41 {
42 return $this->create->legacy()->content(sprintf(
43 '<div><b>%s</b><br/>%s</div>',
44 $this->definition->translatedType(),
45 $this->definition->translatedCountry($this->criterion->arguments()['country'] ?? '')
46 ));
47 }
48
49 public function eval(ilObjUser $user): bool
50 {
51 return strtoupper($user->getCountry()) === strtoupper($this->criterion->arguments()['country']);
52 }
53
55 {
56 return $this->definition;
57 }
58
59 public function knownToNeverMatchWith(Condition $other): bool
60 {
61 return $other instanceof (self::class);
62 }
63}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
__construct(private readonly CriterionContent $criterion, private readonly UserCountryDefinition $definition, private readonly UIFactory $create)
Definition: UserCountry.php:33
User class.
A component is the most general form of an entity in the UI.
Definition: Component.php:28