Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace MediaWiki\Page;
4
5use IDBAccessObject;
6use InvalidArgumentException;
7use MediaWiki\Linker\LinkTarget;
8
9/**
10 * Service for looking up information about wiki pages.
11 *
12 * Default implementation is PageStore.
13 *
14 * @since 1.36
15 * @ingroup Page
16 */
17interface PageLookup {
18
19    /**
20     * Returns the PageIdentity for the given LinkTarget. The page does not have to exist.
21     * Fragments are ignored.
22     *
23     * The LinkTarget must refer to a proper page - that is, it must not be a relative section link,
24     * an interwiki link, or refer to a special page.
25     *
26     * @param LinkTarget $link
27     * @param int $queryFlags
28     *
29     * @throws InvalidArgumentException if $link does not refer to a proper page.
30     * @return ProperPageIdentity
31     */
32    public function getPageForLink(
33        LinkTarget $link,
34        int $queryFlags = IDBAccessObject::READ_NORMAL
35    ): ProperPageIdentity;
36
37    /**
38     * Returns the PageRecord of the given page.
39     *
40     * @param int $pageId
41     * @param int $queryFlags
42     *
43     * @throws InvalidArgumentException if $pageId is 0 or negative.
44     * @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
45     */
46    public function getPageById(
47        int $pageId,
48        int $queryFlags = IDBAccessObject::READ_NORMAL
49    ): ?ExistingPageRecord;
50
51    /**
52     * Returns the PageRecord for the given name and namespace.
53     *
54     * @param int $namespace
55     * @param string $dbKey
56     * @param int $queryFlags
57     *
58     * @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
59     * @throws InvalidArgumentException if $namespace is negative or $dbKey is empty.
60     */
61    public function getPageByName(
62        int $namespace,
63        string $dbKey,
64        int $queryFlags = IDBAccessObject::READ_NORMAL
65    ): ?ExistingPageRecord;
66
67    /**
68     * Returns a PageIdentity for a given user provided page name text.
69     * Returns null if the title is not a valid name of a proper page,
70     * e.g if it is a special page, an interwiki link, a relative section line, or simply invalid.
71     *
72     * @since 1.37
73     *
74     * @param string $text
75     * @param int $defaultNamespace Namespace to assume by default (usually NS_MAIN)
76     * @param int $queryFlags
77     *
78     * @return ProperPageIdentity|null
79     */
80    public function getPageByText(
81        string $text,
82        int $defaultNamespace = NS_MAIN,
83        int $queryFlags = IDBAccessObject::READ_NORMAL
84    ): ?ProperPageIdentity;
85
86    /**
87     * Returns an ExistingPageRecord for a given user provided page name text.
88     *
89     * Returns null if the page does not exist or if title is not a valid name of a proper page,
90     * e.g if it is a special page, an interwiki link, a relative section line, or simply invalid.
91     *
92     * @since 1.37
93     *
94     * @param string $text
95     * @param int $defaultNamespace Namespace to assume by default (usually NS_MAIN)
96     * @param int $queryFlags
97     *
98     * @return ExistingPageRecord|null
99     */
100    public function getExistingPageByText(
101        string $text,
102        int $defaultNamespace = NS_MAIN,
103        int $queryFlags = IDBAccessObject::READ_NORMAL
104    ): ?ExistingPageRecord;
105
106    /**
107     * Returns the PageRecord of the given page.
108     * May return $page if that already is a PageRecord.
109     * If $page is a PageIdentity, implementations may call methods like exists() and getId() on it.
110     *
111     * The PageReference must refer to a proper page - that is, it must not refer to a special page.
112     *
113     * @param PageReference $page
114     * @param int $queryFlags
115     *
116     * @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
117     * @throws InvalidArgumentException if $page does not refer to a proper page.
118     */
119    public function getPageByReference(
120        PageReference $page,
121        int $queryFlags = IDBAccessObject::READ_NORMAL
122    ): ?ExistingPageRecord;
123
124}