ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilCronDefinitionProcessor.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
26  private ?string $component = null;
28  private array $has_cron;
29 
30  public function __construct(
31  private readonly ilDBInterface $db,
32  ilSetting $setting,
33  ilComponentRepository $componentRepository,
34  ilComponentFactory $componentFactory
35  ) {
36  $this->has_cron = [];
37 
38  $this->cronRepository = new ilCronJobRepositoryImpl(
39  $this->db,
40  $setting,
41  new NullLogger(),
42  $componentRepository,
43  $componentFactory
44  );
45  }
46 
47  public function purge(): void
48  {
49  }
50 
51  public function beginComponent(string $component, string $type): void
52  {
53  $this->component = $type . "/" . $component;
54  $this->has_cron = [];
55  }
56 
57  public function endComponent(string $component, string $type): void
58  {
59  $this->component = null;
60  $this->has_cron = [];
61  }
62 
63  public function beginTag(string $name, array $attributes): void
64  {
65  if ($name !== "cron") {
66  return;
67  }
68 
69  $component = $attributes["component"] ?? null;
70  if (!$component) {
71  $component = $this->component;
72  }
73 
74  $this->cronRepository->registerJob(
75  $component,
76  $attributes["id"],
77  $attributes["class"],
78  ($attributes["path"] ?? null)
79  );
80 
81  $this->has_cron[] = $attributes["id"];
82  }
83 
84  public function endTag(string $name): void
85  {
86  if ($name !== "module" && $name !== "service") {
87  return;
88  }
89 
90  $this->cronRepository->unregisterJob($this->component, $this->has_cron);
91  }
92 }
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends. ...
Readable part of repository interface to ilComponentDataDB.
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i.e.
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
readonly ilCronJobRepository $cronRepository
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
endTag(string $name)
This is called when a tag ends in the context of the given component.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
__construct(private readonly ilDBInterface $db, ilSetting $setting, ilComponentRepository $componentRepository, ilComponentFactory $componentFactory)