3 namespace Drupal\Core\Path;
5 use Drupal\Core\Language\LanguageInterface;
8 * Provides a class for CRUD operations on path aliases.
10 interface AliasStorageInterface {
13 * Saves a path alias to the database.
15 * @param string $source
16 * The internal system path.
17 * @param string $alias
19 * @param string $langcode
20 * (optional) The language code of the alias.
21 * @param int|null $pid
22 * (optional) Unique path alias identifier.
25 * FALSE if the path could not be saved or an associative array containing
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.
34 * @thrown \InvalidArgumentException
35 * Thrown when either the source or alias has not a starting slash.
37 public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $pid = NULL);
40 * Fetches a specific URL alias from the database.
42 * The default implementation performs case-insensitive matching on the
43 * 'source' and 'alias' strings.
45 * @param array $conditions
46 * An array of query conditions.
49 * FALSE if no alias was found or an associative array containing the
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.
56 public function load($conditions);
59 * Deletes a URL alias.
61 * The default implementation performs case-insensitive matching on the
62 * 'source' and 'alias' strings.
64 * @param array $conditions
65 * An array of criteria.
67 public function delete($conditions);
70 * Pre-loads path alias information for a given list of source paths.
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.
79 * Source (keys) to alias (values) mapping.
81 public function preloadPathAlias($preloaded, $langcode);
84 * Returns an alias of Drupal system URL.
86 * The default implementation performs case-insensitive matching on the
87 * 'source' and 'alias' strings.
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.
95 * @return string|false
96 * A path alias, or FALSE if no path was found.
98 public function lookupPathAlias($path, $langcode);
101 * Returns Drupal system URL of an alias.
103 * The default implementation performs case-insensitive matching on the
104 * 'source' and 'alias' strings.
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.
112 * @return string|false
113 * A Drupal system path, or FALSE if no path was found.
115 public function lookupPathSource($path, $langcode);
118 * Checks if alias already exists.
120 * The default implementation performs case-insensitive matching on the
121 * 'source' and 'alias' strings.
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.
131 * TRUE if alias already exists and FALSE otherwise.
133 public function aliasExists($alias, $langcode, $source = NULL);
136 * Checks if there are any aliases with language defined.
139 * TRUE if aliases with language exist.
141 public function languageAliasExists();
144 * Loads aliases for admin listing.
146 * @param array $header
148 * @param string|null $keys
149 * (optional) Search keyword that may include one or more '*' as wildcard
153 * Array of items to be displayed on the current page.
155 public function getAliasesForAdminListing($header, $keys = NULL);
158 * Check if any alias exists starting with $initial_substring.
160 * @param string $initial_substring
161 * Initial path substring to test against.
164 * TRUE if any alias exists, FALSE otherwise.
166 public function pathHasMatchingAlias($initial_substring);