ILIAS  release_8 Revision v8.24
class.ilBadgeDefinitionProcessor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected \ilDBInterface $db;
24 protected ?string $component_id;
25 protected bool $has_badges = false;
26
27 public function __construct(\ilDBInterface $db)
28 {
29 $this->db = $db;
30 }
31
32 public function purge(): void
33 {
35 $bh->setComponents(null);
36 }
37
38 public function beginComponent(string $component, string $type): void
39 {
40 $this->has_badges = false;
41 $this->component_id = null;
42 }
43
44 public function endComponent(string $component, string $type): void
45 {
46 $this->has_badges = false;
47 $this->component_id = null;
48 }
49
50 public function beginTag(string $name, array $attributes): void
51 {
52 if ($name === "module" || $name === "service") {
53 $this->component_id = $attributes["id"] ?? null;
54 return;
55 }
56
57 if ($name !== 'badges') {
58 return;
59 }
60
61 if ($this->component_id === null) {
62 throw new \RuntimeException(
63 "Found $name-tag outside of module or service."
64 );
65 }
66
67 ilBadgeHandler::updateFromXML($this->component_id);
68 $this->has_badges = true;
69 }
70
71 public function endTag(string $name): void
72 {
73 if ($name === "module" || $name === "service") {
74 $this->component_id = null;
75 }
76 }
77}
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.
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.
if($format !==null) $name
Definition: metadata.php:247
$attributes
Definition: metadata.php:248
$type