ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MissingPageDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Wiki\Links;
22
24
29{
31 protected \ilDBInterface $db;
32
33 public function __construct(
36 ) {
37 $this->data = $data;
38 $this->db = $db;
39 }
40
41 public function save(int $wiki_id, int $source_id, string $title, string $lang): void
42 {
43 $this->db->replace(
44 "il_wiki_missing_page",
45 [
46 "wiki_id" => ["integer", $wiki_id],
47 "source_id" => ["integer", $source_id],
48 "target_name" => ["text", \ilWikiUtil::makeDbTitle($title)],
49 "lang" => ["text", $lang]
50 ],
51 []
52 );
53 }
54
55 public function deleteForTarget(int $wiki_id, string $target_title, string $lang = "-"): void
56 {
57 $this->db->manipulateF(
58 "DELETE FROM il_wiki_missing_page WHERE " .
59 " wiki_id = %s AND target_name = %s AND lang = %s",
60 array("integer", "text", "text"),
61 array($wiki_id, \ilWikiUtil::makeDbTitle($target_title), $lang)
62 );
63 }
64
65 public function deleteForSourceId(int $wiki_id, int $source_id, string $lang = "-"): void
66 {
67 $this->db->manipulateF(
68 "DELETE FROM il_wiki_missing_page WHERE " .
69 " wiki_id = %s AND source_id = %s AND lang = %s",
70 array("integer", "integer", "text"),
71 array($wiki_id, $source_id, $lang)
72 );
73 }
74
78 public function getSourcesOfMissingTarget(int $wiki_id, string $target_title, string $lang = "-"): \Iterator
79 {
80 $set = $this->db->queryF(
81 "SELECT source_id FROM il_wiki_missing_page WHERE " .
82 " wiki_id = %s AND target_name = %s AND lang = %s",
83 array("integer", "text", "text"),
84 array($wiki_id, \ilWikiUtil::makeDbTitle($target_title), $lang)
85 );
86 while ($rec = $this->db->fetchAssoc($set)) {
87 yield (int) $rec["source_id"];
88 }
89 }
90
91}
Repository internal data service.
static makeDbTitle(string $a_par)
Interface ilDBInterface.
$lang
Definition: xapiexit.php:25