Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Sql / TableMappingInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity\Sql;
4
5 use Drupal\Core\Field\FieldStorageDefinitionInterface;
6
7 /**
8  * Provides a common interface for mapping field columns to SQL tables.
9  *
10  * Warning: using methods provided here should be done only when writing code
11  * that is explicitly targeting a SQL-based entity storage. Typically this API
12  * is used by SQL storage classes, or other SQL-specific code like the Views
13  * integration code for the Entity SQL storage. Another example of legal usage
14  * of this API is when needing to write a query that \Drupal::entityQuery() does
15  * not support. Always retrieve entity identifiers and use them to load entities
16  * instead of accessing data stored in the database directly. Any other usage
17  * circumvents the entity system and is strongly discouraged, at least when
18  * writing contributed code.
19  */
20 interface TableMappingInterface {
21
22   /**
23    * A property that represents delta used in entity query conditions.
24    */
25   const DELTA = '%delta';
26
27   /**
28    * Gets a list of table names for this mapping.
29    *
30    * @return string[]
31    *   An array of table names.
32    */
33   public function getTableNames();
34
35   /**
36    * Gets a list of all database columns for a given table.
37    *
38    * @param string $table_name
39    *   The name of the table to return the columns for.
40    *
41    * @return string[]
42    *   An array of database column names for this table. Both field columns and
43    *   extra columns are returned.
44    */
45   public function getAllColumns($table_name);
46
47   /**
48    * Gets a list of names for entity fields stored in the specified table.
49    *
50    * The return list is contains the entity field names, not database field
51    * (i.e. column) names. To get the mapping of specific entity field to
52    * database columns use ::getColumnNames().
53    *
54    * @param string $table_name
55    *   The name of the table to return the field names for.
56    *
57    * @return string[]
58    *   An array of field names for the given table.
59    */
60   public function getFieldNames($table_name);
61
62   /**
63    * Gets a mapping of field columns to database columns for a given field.
64    *
65    * @param string $field_name
66    *   The name of the entity field to return the column mapping for.
67    *
68    * @return string[]
69    *   The keys of this array are the keys of the array returned by
70    *   FieldStorageDefinitionInterface::getColumns() while the respective values
71    *   are the names of the database columns for this table mapping.
72    */
73   public function getColumnNames($field_name);
74
75   /**
76    * Gets a list of extra database columns, which store denormalized data.
77    *
78    * These database columns do not belong to any entity fields. Any normalized
79    * data that is stored should be associated with an entity field.
80    *
81    * @param string $table_name
82    *   The name of the table to return the columns for.
83    *
84    * @return string[]
85    *   An array of column names for the given table.
86    */
87   public function getExtraColumns($table_name);
88
89   /**
90    * Gets the list of columns that can not be used as field type columns.
91    *
92    * @return array
93    */
94   public function getReservedColumns();
95
96   /**
97    * Generates a column name for a field property.
98    *
99    * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
100    *   The field storage definition.
101    * @param string $property_name
102    *   The name of the property.
103    *
104    * @return string
105    *   A string containing a generated column name for a field data table that is
106    *   unique among all other fields.
107    */
108   public function getFieldColumnName(FieldStorageDefinitionInterface $storage_definition, $property_name);
109
110   /**
111    * Gets the table name for a given column.
112    *
113    * @param string $field_name
114    *   The name of the entity field to return the column mapping for.
115    *
116    * @return string
117    *   Table name for the given field.
118    *
119    * @throws \Drupal\Core\Entity\Sql\SqlContentEntityStorageException
120    */
121   public function getFieldTableName($field_name);
122
123 }