Version 1
[yaffs-website] / web / modules / contrib / pathauto / src / AliasStorageHelperInterface.php
1 <?php
2
3 namespace Drupal\pathauto;
4 use Drupal\Core\Entity\EntityInterface;
5 use Drupal\Core\Language\LanguageInterface;
6
7 /**
8  * Provides helper methods for accessing alias storage.
9  */
10 interface AliasStorageHelperInterface {
11
12   /**
13    * Fetch the maximum length of the {url_alias}.alias field from the schema.
14    *
15    * @return int
16    *   An integer of the maximum URL alias length allowed by the database.
17    */
18   public function getAliasSchemaMaxLength();
19
20   /**
21    * Private function for Pathauto to create an alias.
22    *
23    * @param array $path
24    *   An associative array containing the following keys:
25    *   - source: The internal system path.
26    *   - alias: The URL alias.
27    *   - pid: (optional) Unique path alias identifier.
28    *   - language: (optional) The language of the alias.
29    * @param array|bool|null $existing_alias
30    *   (optional) An associative array of the existing path alias.
31    * @param string $op
32    *   An optional string with the operation being performed.
33    *
34    * @return array|bool
35    *   The saved path or NULL if the path was not saved.
36    */
37   public function save(array $path, $existing_alias = NULL, $op = NULL);
38
39   /**
40    * Fetches an existing URL alias given a path and optional language.
41    *
42    * @param string $source
43    *   An internal Drupal path.
44    * @param string $language
45    *   An optional language code to look up the path in.
46    *
47    * @return bool|array
48    *   FALSE if no alias was found or an associative array containing the
49    *   following keys:
50    *   - source (string): The internal system path with a starting slash.
51    *   - alias (string): The URL alias with a starting slash.
52    *   - pid (int): Unique path alias identifier.
53    *   - langcode (string): The language code of the alias.
54    */
55   public function loadBySource($source, $language = LanguageInterface::LANGCODE_NOT_SPECIFIED);
56
57   /**
58    * Delete all aliases by source url.
59    *
60    * @param string $source
61    *   An internal Drupal path.
62    *
63    * @return bool
64    *   The URL alias source.
65    */
66   public function deleteBySourcePrefix($source);
67
68   /**
69    * Delete all aliases (truncate the url_alias table).
70    */
71   public function deleteAll();
72
73   /**
74    * Delete an entity URL alias and any of its sub-paths.
75    *
76    * This function also checks to see if the default entity URI is different
77    * from the current entity URI and will delete any of the default aliases.
78    *
79    * @param \Drupal\Core\Entity\EntityInterface $entity
80    *   An entity object.
81    * @param string $default_uri
82    *   The optional default uri path for the entity.
83    */
84   public function deleteEntityPathAll(EntityInterface $entity, $default_uri = NULL);
85
86   /**
87    * Fetches an existing URL alias given a path prefix.
88    *
89    * @param string $source
90    *   An internal Drupal path prefix.
91    *
92    * @return integer[]
93    *   An array of PIDs.
94    */
95   public function loadBySourcePrefix($source);
96
97
98   /**
99    * Returns the count of url aliases for the source.
100    *
101    * @param $source
102    *   An internal Drupal path prefix.
103    *
104    * @return int
105    *   Number of url aliases for the source.
106    */
107   public function countBySourcePrefix($source);
108
109   /**
110    * Returns the total count of the url aliases.
111    *
112    * @return int
113    *   Total number of aliases.
114    */
115   public function countAll();
116
117 }