ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBadgeDefinitionProcessor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ?string $component_id;
24 protected bool $has_badges = false;
25
26 public function __construct(protected ilDBInterface $db)
27 {
28 }
29
30 public function purge(): void
31 {
33 $bh->setComponents(null);
34 }
35
36 public function beginComponent(string $component, string $type): void
37 {
38 $this->has_badges = false;
39 $this->component_id = null;
40 }
41
42 public function endComponent(string $component, string $type): void
43 {
44 $this->has_badges = false;
45 $this->component_id = null;
46 }
47
48 public function beginTag(string $name, array $attributes): void
49 {
50 if ($name === 'module' || $name === 'service') {
51 $this->component_id = $attributes['id'] ?? null;
52 return;
53 }
54
55 if ($name !== 'badges') {
56 return;
57 }
58
59 if ($this->component_id === null) {
60 throw new RuntimeException(
61 "Found $name-tag outside of module or service."
62 );
63 }
64
65 ilBadgeHandler::updateFromXML($this->component_id);
66 $this->has_badges = true;
67 }
68
69 public function endTag(string $name): void
70 {
71 if ($name === 'module' || $name === 'service') {
72 $this->component_id = null;
73 }
74 }
75}
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
__construct(protected ilDBInterface $db)
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
endTag(string $name)
This is called when a tag ends in the context of the given component.
static updateFromXML(string $a_component_id)
Import component definition.
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i....
Interface ilDBInterface.