Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Path / AliasStorageInterface.php
1 <?php
2
3 namespace Drupal\Core\Path;
4
5 use Drupal\Core\Language\LanguageInterface;
6
7 /**
8  * Provides a class for CRUD operations on path aliases.
9  */
10 interface AliasStorageInterface {
11
12   /**
13    * Saves a path alias to the database.
14    *
15    * @param string $source
16    *   The internal system path.
17    * @param string $alias
18    *   The URL alias.
19    * @param string $langcode
20    *   (optional) The language code of the alias.
21    * @param int|null $pid
22    *   (optional) Unique path alias identifier.
23    *
24    * @return array|false
25    *   FALSE if the path could not be saved or an associative array containing
26    *   the following keys:
27    *   - source (string): The internal system path with a starting slash.
28    *   - alias (string): The URL alias with a starting slash.
29    *   - pid (int): Unique path alias identifier.
30    *   - langcode (string): The language code of the alias.
31    *   - original: For updates, an array with source, alias and langcode with
32    *     the previous values.
33    *
34    * @thrown \InvalidArgumentException
35    *   Thrown when either the source or alias has not a starting slash.
36    */
37   public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL);
38
39   /**
40    * Fetches a specific URL alias from the database.
41    *
42    * The default implementation performs case-insensitive matching on the
43    * 'source' and 'alias' strings.
44    *
45    * @param array $conditions
46    *   An array of query conditions.
47    *
48    * @return array|false
49    *   FALSE if no alias was found or an associative array containing the
50    *   following keys:
51    *   - source (string): The internal system path with a starting slash.
52    *   - alias (string): The URL alias with a starting slash.
53    *   - pid (int): Unique path alias identifier.
54    *   - langcode (string): The language code of the alias.
55    */
56   public function load($conditions);
57
58   /**
59    * Deletes a URL alias.
60    *
61    * The default implementation performs case-insensitive matching on the
62    * 'source' and 'alias' strings.
63    *
64    * @param array $conditions
65    *   An array of criteria.
66    */
67   public function delete($conditions);
68
69   /**
70    * Pre-loads path alias information for a given list of source paths.
71    *
72    * @param array $preloaded
73    *   Paths that need preloading of aliases.
74    * @param string $langcode
75    *   Language code to search the path with. If there's no path defined for
76    *   that language it will search paths without language.
77    *
78    * @return string[]
79    *   Source (keys) to alias (values) mapping.
80    */
81   public function preloadPathAlias($preloaded, $langcode);
82
83   /**
84    * Returns an alias of Drupal system URL.
85    *
86    * The default implementation performs case-insensitive matching on the
87    * 'source' and 'alias' strings.
88    *
89    * @param string $path
90    *   The path to investigate for corresponding path aliases.
91    * @param string $langcode
92    *   Language code to search the path with. If there's no path defined for
93    *   that language it will search paths without language.
94    *
95    * @return string|false
96    *   A path alias, or FALSE if no path was found.
97    */
98   public function lookupPathAlias($path, $langcode);
99
100   /**
101    * Returns Drupal system URL of an alias.
102    *
103    * The default implementation performs case-insensitive matching on the
104    * 'source' and 'alias' strings.
105    *
106    * @param string $path
107    *   The path to investigate for corresponding system URLs.
108    * @param string $langcode
109    *   Language code to search the path with. If there's no path defined for
110    *   that language it will search paths without language.
111    *
112    * @return string|false
113    *   A Drupal system path, or FALSE if no path was found.
114    */
115   public function lookupPathSource($path, $langcode);
116
117   /**
118    * Checks if alias already exists.
119    *
120    * The default implementation performs case-insensitive matching on the
121    * 'source' and 'alias' strings.
122    *
123    * @param string $alias
124    *   Alias to check against.
125    * @param string $langcode
126    *   Language of the alias.
127    * @param string|null $source
128    *   (optional) Path that alias is to be assigned to.
129    *
130    * @return bool
131    *   TRUE if alias already exists and FALSE otherwise.
132    */
133   public function aliasExists($alias, $langcode, $source = NULL);
134
135   /**
136    * Checks if there are any aliases with language defined.
137    *
138    * @return bool
139    *   TRUE if aliases with language exist.
140    */
141   public function languageAliasExists();
142
143   /**
144    * Loads aliases for admin listing.
145    *
146    * @param array $header
147    *   Table header.
148    * @param string|null $keys
149    *   (optional) Search keyword that may include one or more '*' as wildcard
150    *   values.
151    *
152    * @return array
153    *   Array of items to be displayed on the current page.
154    */
155   public function getAliasesForAdminListing($header, $keys = NULL);
156
157   /**
158    * Check if any alias exists starting with $initial_substring.
159    *
160    * @param string $initial_substring
161    *   Initial path substring to test against.
162    *
163    * @return bool
164    *   TRUE if any alias exists, FALSE otherwise.
165    */
166   public function pathHasMatchingAlias($initial_substring);
167
168 }