diff --git a/core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php b/core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php index b4c6720..476dffb 100644 --- a/core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php +++ b/core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php @@ -9,7 +9,6 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\field\FieldInstanceInterface; -use Drupal\field\FieldInterface; /** * A common base class for configurable entity reference fields. @@ -78,13 +77,13 @@ public function getPropertyDefinitions() { * Copied from \Drupal\field\Plugin\Field\FieldType\LegacyConfigFieldItem, * since we cannot extend it. */ - public static function schema(FieldInterface $field) { - $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type); + public static function schema(FieldDefinitionInterface $field_definition) { + $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_definition->type); $module = $definition['provider']; module_load_install($module); $callback = "{$module}_field_schema"; if (function_exists($callback)) { - return $callback($field); + return $callback($field_definition); } } diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemInterface.php b/core/lib/Drupal/Core/Field/ConfigFieldItemInterface.php index 555070a..980714d 100644 --- a/core/lib/Drupal/Core/Field/ConfigFieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemInterface.php @@ -7,48 +7,12 @@ namespace Drupal\Core\Field; -use Drupal\field\FieldInterface; - /** * Interface definition for 'configurable field type' plugins. */ interface ConfigFieldItemInterface extends FieldItemInterface { /** - * Returns the schema for the field. - * - * This method is static, because the field schema information is needed on - * creation of the field. No field instances exist by then, and it is not - * possible to instantiate a FieldItemInterface object yet. - * - * @param \Drupal\field\FieldInterface $field - * The field definition. - * - * @return array - * An associative array with the following key/value pairs: - * - columns: An array of Schema API column specifications, keyed by column - * name. This specifies what comprises a value for a given field. For - * example, a value for a number field is simply 'value', while a value - * for a formatted text field is the combination of 'value' and 'format'. - * It is recommended to avoid having the column definitions depend on - * field settings when possible. No assumptions should be made on how - * storage engines internally use the original column name to structure - * their storage. - * - indexes: (optional) An array of Schema API index definitions. Only - * columns that appear in the 'columns' array are allowed. Those indexes - * will be used as default indexes. Callers of field_create_field() can - * specify additional indexes or, at their own risk, modify the default - * indexes specified by the field-type module. Some storage engines might - * not support indexes. - * - foreign keys: (optional) An array of Schema API foreign key - * definitions. Note, however, that the field data is not necessarily - * stored in SQL. Also, the possible usage is limited, as you cannot - * specify another field as related, only existing SQL tables, - * such as {taxonomy_term_data}. - */ - public static function schema(FieldInterface $field); - - /** * Returns a form for the field-level settings. * * Invoked from \Drupal\field_ui\Form\FieldEditForm to allow administrators to diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php index 640bee3..9e88c57 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Field/FieldDefinition.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\ListDefinition; +use Drupal\field\FieldException; /** * A class for defining entity fields. @@ -17,6 +18,13 @@ class FieldDefinition extends ListDefinition implements FieldDefinitionInterface, \ArrayAccess { /** + * The field schema. + * + * @var array + */ + protected $schema; + + /** * Creates a new field definition. * * @param string $type @@ -324,4 +332,55 @@ public function offsetSet($offset, $value) { $this->definition[$offset] = $value; } } + + /** + * {@inheritdoc} + */ + public function getSchema() { + if (!isset($this->schema)) { + // Get the schema from the field item class. + $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getFieldType()); + $class = $definition['class']; + $schema = $class::schema($this); + // Fill in default values for optional entries. + $schema += array('indexes' => array(), 'foreign keys' => array()); + + // Check that the schema does not include forbidden column names. + if (array_intersect(array_keys($schema['columns']), static::getReservedColumns())) { + throw new FieldException('Illegal field type columns.'); + } + + // Merge custom indexes with those specified by the field type. Custom + // indexes prevail. + $schema['indexes'] = $this->indexes + $schema['indexes']; + + $this->schema = $schema; + } + + return $this->schema; + } + + /** + * {@inheritdoc} + */ + public function getColumns() { + $schema = $this->getSchema(); + // A typical use case for the method is to iterate on the columns, while + // some other use cases rely on identifying the first column with the key() + // function. Since the schema is persisted in the Field object, we take care + // of resetting the array pointer so that the former does not interfere with + // the latter. + reset($schema['columns']); + return $schema['columns']; + } + + /** + * A list of columns that can not be used as field type columns. + * + * @return array + */ + public static function getReservedColumns() { + return array('deleted'); + } + } diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index 4dca17a..274f61c 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -209,4 +209,33 @@ public function isFieldMultiple(); */ public function getFieldDefaultValue(EntityInterface $entity); + /** + * Returns the field schema. + * + * @return array + * The field schema, as an array of key/value pairs in the format returned + * by hook_field_schema(): + * - columns: An array of Schema API column specifications, keyed by column + * name. This specifies what comprises a single value for a given field. + * No assumptions should be made on how storage backends internally use + * the original column name to structure their storage. + * - indexes: An array of Schema API index definitions. Some storage + * backends might not support indexes. + * - foreign keys: An array of Schema API foreign key definitions. Note, + * however, that depending on the storage backend specified for the field, + * the field data is not necessarily stored in SQL. + */ + public function getSchema(); + + /** + * Returns the field columns, as defined in the field schema. + * + * @return array + * The array of field columns, keyed by column name, in the same format + * returned by getSchema(). + * + * @see \Drupal\field\Entity\FieldInterface::getSchema() + */ + public function getColumns(); + } diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index 5524cb4..e38fbed 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -24,6 +24,41 @@ interface FieldItemInterface extends ComplexDataInterface { /** + * Returns the schema for the field. + * + * This method is static, because the field schema information is needed on + * creation of the field. No field instances exist by then, and it is not + * possible to instantiate a FieldItemInterface object yet. + * + * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition + * The field definition. + * + * @return array + * An associative array with the following key/value pairs: + * - columns: An array of Schema API column specifications, keyed by column + * name. The columns need to be a subset of the properties defined in + * getPropertyDefinitions(). This specifies what comprises a value for a + * given field. For example, a value for a number field is simply 'value', + * while a value for a formatted text field is the combination of 'value' + * and 'format'. It is recommended to avoid having the column definitions + * depend on field settings when possible. No assumptions should be made + * on how storage engines internally use the original column name to + * structure their storage. + * - indexes: (optional) An array of Schema API index definitions. Only + * columns that appear in the 'columns' array are allowed. Those indexes + * will be used as default indexes. Callers of field_create_field() can + * specify additional indexes or, at their own risk, modify the default + * indexes specified by the field-type module. Some storage engines might + * not support indexes. + * - foreign keys: (optional) An array of Schema API foreign key + * definitions. Note, however, that the field data is not necessarily + * stored in SQL. Also, the possible usage is limited, as you cannot + * specify another field as related, only existing SQL tables, + * such as {taxonomy_term_data}. + */ + public static function schema(FieldDefinitionInterface $field_definition); + + /** * Gets the entity that field belongs to. * * @return \Drupal\Core\Entity\EntityInterface diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index fe7ba96..caf1d24 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -43,4 +44,21 @@ public function getPropertyDefinitions() { } return static::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), + ), + ); + } + } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DateItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DateItem.php index 59984c8..8c5a82c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DateItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DateItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -43,4 +44,20 @@ public function getPropertyDefinitions() { } return static::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + ); + } + } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php index ce0817c..df510bd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -22,6 +23,18 @@ class EmailItem extends FieldItemBase { /** + * Defines the max length for an email address + * + * The maximum length of an e-mail address is 254 characters. RFC 3696 + * specifies a total length of 320 characters, but mentions that + * addresses longer than 256 characters are not normally useful. Erratum + * 1690 was then released which corrected this value to 254 characters. + * @see http://tools.ietf.org/html/rfc3696#section-3 + * @see http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690 + */ + const EMAIL_MAX_LENGTH = 254; + + /** * Definitions of the contained properties. * * @see EmailItem::getPropertyDefinitions() @@ -44,6 +57,39 @@ public function getPropertyDefinitions() { return static::$propertyDefinitions; } + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'varchar', + 'length' => static::EMAIL_MAX_LENGTH, + 'not null' => FALSE, + ), + ), + ); + } + + /** + * {@inheritdoc} + */ + public function getConstraints() { + $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); + $constraints = parent::getConstraints(); + + $constraints[] = $constraint_manager->create('ComplexData', array( + 'value' => array( + 'Length' => array( + 'max' => static::EMAIL_MAX_LENGTH, + 'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => static::EMAIL_MAX_LENGTH)), + ) + ), + )); + + return $constraints; + } /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 61f624f..1617504 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -88,6 +89,43 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ + public static function schema(FieldDefinitionInterface $field_definition) { + $target_type = $field_definition->getFieldSetting('target_type'); + $target_type_info = \Drupal::entityManager()->getDefinition($target_type); + + if (is_subclass_of($target_type_info['class'], '\Drupal\Core\Entity\ContentEntityInterface')) { + $columns = array( + 'target_id' => array( + 'description' => 'The ID of the target entity.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + ); + } + else { + $columns = array( + 'target_id' => array( + 'description' => 'The ID of the target entity.', + 'type' => 'varchar', + 'length' => '255', + ), + ); + } + + $schema = array( + 'columns' => $columns, + 'indexes' => array( + 'target_id' => array('target_id'), + ), + ); + + return $schema; + } + + /** + * {@inheritdoc} + */ public function __get($name) { $name = ($name == 'value') ? 'target_id' : $name; return parent::__get($name); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php index ccfd3c5..27a6001 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -43,4 +44,19 @@ public function getPropertyDefinitions() { } return static::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'float', + 'not null' => FALSE, + ), + ), + ); + } + } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php index 82f088a..1e084dc 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\TypedData\DataDefinition; @@ -42,4 +43,20 @@ public function getPropertyDefinitions() { } return static::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + ); + } + } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 3ed6127..89ce29d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Language\Language; @@ -60,6 +61,22 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + ), + ); + } + + /** + * {@inheritdoc} + */ public function setValue($values, $notify = TRUE) { // Treat the values as property value of the language property, if no array // is given as this handles language codes and objects. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php index 336f0f8..dc73093 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LegacyConfigFieldItem.php @@ -7,10 +7,10 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Field\ConfigFieldItemBase; -use Drupal\field\FieldInterface; use Drupal\field\FieldInstanceInterface; /** @@ -31,13 +31,13 @@ /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { - $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type); + public static function schema(FieldDefinitionInterface $field_definition) { + $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_definition->type); $module = $definition['provider']; module_load_install($module); $callback = "{$module}_field_schema"; if (function_exists($callback)) { - return $callback($field); + return $callback($field_definition); } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 9c63b33..43dfaf2 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\TypedData\DataDefinition; @@ -17,6 +18,9 @@ * id = "string", * label = @Translation("String"), * description = @Translation("An entity field containing a string value."), + * settings = { + * "max_length" = "255" + * }, * configurable = FALSE * ) */ @@ -42,4 +46,20 @@ public function getPropertyDefinitions() { } return static::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'varchar', + 'length' => $field_definition->getFieldSetting('max_length'), + 'not null' => FALSE, + ), + ), + ); + } + } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php index 23f9701..d920b2d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -43,4 +44,19 @@ public function getPropertyDefinitions() { } return self::$propertyDefinitions; } + + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array( + 'columns' => array( + 'value' => array( + 'type' => 'text', + 'not null' => FALSE, + ), + ), + ); + } + } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index c91f1bb..b3f16cc 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\ConfigFieldItemBase; /** @@ -79,7 +79,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'status' => array( diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php index e4cad9a..0f91e14 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php @@ -7,9 +7,8 @@ namespace Drupal\datetime\Plugin\Field\FieldType; -use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; -use Drupal\field\FieldInterface; use Drupal\Core\Field\ConfigFieldItemBase; /** @@ -65,7 +64,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php index 5b0ff24..65e08da 100644 --- a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php +++ b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php @@ -7,8 +7,8 @@ namespace Drupal\email; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; -use Drupal\field\FieldInterface; use Drupal\Core\Field\ConfigFieldItemInterface; /** @@ -19,52 +19,6 @@ class ConfigurableEmailItem extends EmailItem implements ConfigFieldItemInterface { /** - * Defines the max length for an email address - * - * The maximum length of an e-mail address is 254 characters. RFC 3696 - * specifies a total length of 320 characters, but mentions that - * addresses longer than 256 characters are not normally useful. Erratum - * 1690 was then released which corrected this value to 254 characters. - * @see http://tools.ietf.org/html/rfc3696#section-3 - * @see http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690 - */ - const EMAIL_MAX_LENGTH = 254; - - /** - * {@inheritdoc} - */ - public static function schema(FieldInterface $field) { - return array( - 'columns' => array( - 'value' => array( - 'type' => 'varchar', - 'length' => static::EMAIL_MAX_LENGTH, - 'not null' => FALSE, - ), - ), - ); - } - - /** - * {@inheritdoc} - */ - public function getConstraints() { - $constraint_manager = \Drupal::typedData()->getValidationConstraintManager(); - $constraints = parent::getConstraints(); - - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Length' => array( - 'max' => static::EMAIL_MAX_LENGTH, - 'maxMessage' => t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getFieldLabel(), '@max' => static::EMAIL_MAX_LENGTH)), - ) - ), - )); - - return $constraints; - } - - /** * {@inheritdoc} */ public function settingsForm(array $form, array &$form_state, $has_data) { diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php index bf58a7f..09f6b4d 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php @@ -7,9 +7,10 @@ namespace Drupal\entity_reference; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\ConfigEntityReferenceItemBase; use Drupal\Core\Field\ConfigFieldItemInterface; +use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; /** * Alternative plugin implementation of the 'entity_reference' field type. @@ -25,43 +26,21 @@ class ConfigurableEntityReferenceItem extends ConfigEntityReferenceItemBase impl /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { - $target_type = $field->getFieldSetting('target_type'); + public static function schema(FieldDefinitionInterface $field_definition) { + $schema = EntityReferenceItem::schema($field_definition); + + $target_type = $field_definition->getFieldSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); if (is_subclass_of($target_type_info['class'], '\Drupal\Core\Entity\ContentEntityInterface')) { - $columns = array( - 'target_id' => array( - 'description' => 'The ID of the target entity.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'revision_id' => array( - 'description' => 'The revision ID of the target entity.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - ), - ); - } - else { - $columns = array( - 'target_id' => array( - 'description' => 'The ID of the target entity.', - 'type' => 'varchar', - 'length' => '255', - ), + $schema['columns']['revision_id'] = array( + 'description' => 'The revision ID of the target entity.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, ); } - $schema = array( - 'columns' => $columns, - 'indexes' => array( - 'target_id' => array('target_id'), - ), - ); - return $schema; } diff --git a/core/modules/field/lib/Drupal/field/Entity/Field.php b/core/modules/field/lib/Drupal/field/Entity/Field.php index fc52346..4e1c083 100644 --- a/core/modules/field/lib/Drupal/field/Entity/Field.php +++ b/core/modules/field/lib/Drupal/field/Entity/Field.php @@ -185,13 +185,6 @@ class Field extends ConfigEntityBase implements FieldInterface { public $deleted = FALSE; /** - * The field schema. - * - * @var array - */ - protected $schema; - - /** * The original field. * * @var \Drupal\field\Entity\Field diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php index 7e34d3d..1c01abd 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php @@ -691,4 +691,19 @@ public function getItemDefinition() { } return $this->itemDefinition; } + + /** + * {@inheritdoc} + */ + public function getSchema() { + return $this->field->getSchema(); + } + + /** + * {@inheritdoc} + */ + public function getColumns() { + return $this->field->getColumns(); + } + } diff --git a/core/modules/field/lib/Drupal/field/FieldInterface.php b/core/modules/field/lib/Drupal/field/FieldInterface.php index 78de421..ed2658c 100644 --- a/core/modules/field/lib/Drupal/field/FieldInterface.php +++ b/core/modules/field/lib/Drupal/field/FieldInterface.php @@ -16,35 +16,6 @@ interface FieldInterface extends ConfigEntityInterface, FieldDefinitionInterface { /** - * Returns the field schema. - * - * @return array - * The field schema, as an array of key/value pairs in the format returned - * by hook_field_schema(): - * - columns: An array of Schema API column specifications, keyed by column - * name. This specifies what comprises a single value for a given field. - * No assumptions should be made on how storage backends internally use - * the original column name to structure their storage. - * - indexes: An array of Schema API index definitions. Some storage - * backends might not support indexes. - * - foreign keys: An array of Schema API foreign key definitions. Note, - * however, that depending on the storage backend specified for the field, - * the field data is not necessarily stored in SQL. - */ - public function getSchema(); - - /** - * Returns the field columns, as defined in the field schema. - * - * @return array - * The array of field columns, keyed by column name, in the same format - * returned by getSchema(). - * - * @see \Drupal\field\Entity\FieldInterface::getSchema() - */ - public function getColumns(); - - /** * Returns the list of bundles where the field has instances. * * @return array diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php index 32dedba..efcf30c 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php @@ -7,7 +7,7 @@ namespace Drupal\field_test\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\ConfigFieldItemBase; /** @@ -56,16 +56,16 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { $foreign_keys = array(); // The 'foreign keys' key is not always used in tests. - if ($field->getFieldSetting('foreign_key_name')) { + if ($field_definition->getFieldSetting('foreign_key_name')) { $foreign_keys['foreign keys'] = array( // This is a dummy foreign key definition, references a table that // doesn't exist, but that's not a problem. - $field->getFieldSetting('foreign_key_name') => array( - 'table' => $field->getFieldSetting('foreign_key_name'), - 'columns' => array($field->getFieldSetting('foreign_key_name') => 'id'), + $field_definition->getFieldSetting('foreign_key_name') => array( + 'table' => $field_definition->getFieldSetting('foreign_key_name'), + 'columns' => array($field_definition->getFieldSetting('foreign_key_name') => 'id'), ), ); } diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php index 79ac618..1168c6f 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php @@ -7,10 +7,8 @@ namespace Drupal\field_test\Plugin\Field\FieldType; -use Drupal\Core\Entity\Annotation\FieldType; -use Drupal\Core\Annotation\Translation; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; -use Drupal\field\FieldInterface; use Drupal\Core\Field\ConfigFieldItemBase; /** @@ -61,7 +59,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php index 2173689..4ec318f 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php @@ -7,8 +7,8 @@ namespace Drupal\file\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; -use Drupal\field\FieldInterface; use Drupal\Core\Field\ConfigFieldItemInterface; /** @@ -48,7 +48,7 @@ class FileItem extends EntityReferenceItem implements ConfigFieldItemInterface { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'target_id' => array( diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php index b697465..7c18e3a 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -7,7 +7,7 @@ namespace Drupal\image\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\file\Plugin\Field\FieldType\FileItem; /** @@ -69,7 +69,7 @@ class ImageItem extends FileItem { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'target_id' => array( diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php index 55fcc38..1db5afe 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php @@ -8,7 +8,7 @@ namespace Drupal\link\Plugin\Field\FieldType; use Drupal\Core\Field\ConfigFieldItemBase; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'link' field type. @@ -57,7 +57,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'url' => array( diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php index 6dbb3c4..b0d8497 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php @@ -7,7 +7,7 @@ namespace Drupal\number\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Component\Utility\MapArray; /** @@ -49,13 +49,13 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( 'type' => 'numeric', - 'precision' => $field->settings['precision'], - 'scale' => $field->settings['scale'], + 'precision' => $field_definition->settings['precision'], + 'scale' => $field_definition->settings['scale'], 'not null' => FALSE ) ), diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/FloatItem.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/FloatItem.php index 3a58097..076861e 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/FloatItem.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/FloatItem.php @@ -7,7 +7,7 @@ namespace Drupal\number\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'number_float' field type. @@ -44,7 +44,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/IntegerItem.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/IntegerItem.php index 52954df..638dcd5 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/IntegerItem.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/IntegerItem.php @@ -7,7 +7,7 @@ namespace Drupal\number\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'number_integer' field type. @@ -44,7 +44,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php index 1b0ce50..2fa23d7 100644 --- a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php @@ -7,6 +7,7 @@ namespace Drupal\path\Plugin\Field\FieldType; +use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemBase; /** @@ -47,4 +48,11 @@ public function getPropertyDefinitions() { return static::$propertyDefinitions; } + /** + * {@inheritdoc} + */ + public static function schema(FieldDefinitionInterface $field_definition) { + return array(); + } + } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 883faae..1bb6780 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -7,6 +7,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache; +use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Language\Language; use Drupal\Core\Utility\ModuleInfo; use Drupal\user\UserInterface; @@ -343,7 +344,7 @@ function system_element_info() { '#input' => TRUE, '#size' => 60, // user.module is not loaded in case of early bootstrap errors. - '#maxlength' => defined('EMAIL_MAX_LENGTH') ? EMAIL_MAX_LENGTH : 255, + '#maxlength' => EmailItem::EMAIL_MAX_LENGTH, '#autocomplete_route_name' => FALSE, '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'), '#element_validate' => array('form_validate_email'), diff --git a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php index 032da92..8a0f7f1 100644 --- a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php +++ b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php @@ -8,7 +8,7 @@ namespace Drupal\telephone\Plugin\Field\FieldType; use Drupal\Core\Field\ConfigFieldItemBase; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'telephone' field type. @@ -33,7 +33,7 @@ class TelephoneItem extends ConfigFieldItemBase { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php index ec92b9d..04b5a0c 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php @@ -7,7 +7,7 @@ namespace Drupal\text\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'text' field type. @@ -31,12 +31,12 @@ class TextItem extends TextItemBase { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( 'type' => 'varchar', - 'length' => $field->settings['max_length'], + 'length' => $field_definition->settings['max_length'], 'not null' => FALSE, ), 'format' => array( diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php index 37c4445..b40a6c5 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextLongItem.php @@ -7,7 +7,7 @@ namespace Drupal\text\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'text_long' field type. @@ -28,7 +28,7 @@ class TextLongItem extends TextItemBase { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php index 0d3c138..2441507 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -7,7 +7,7 @@ namespace Drupal\text\Plugin\Field\FieldType; -use Drupal\field\FieldInterface; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Plugin implementation of the 'text_with_summary' field type. @@ -61,7 +61,7 @@ public function getPropertyDefinitions() { /** * {@inheritdoc} */ - public static function schema(FieldInterface $field) { + public static function schema(FieldDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index 2399a58..a547c02 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -7,6 +7,7 @@ namespace Drupal\user\Form; +use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Form\FormBase; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; @@ -74,7 +75,7 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'textfield', '#title' => $this->t('Username or e-mail address'), '#size' => 60, - '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH), + '#maxlength' => max(USERNAME_MAX_LENGTH, EmailItem::EMAIL_MAX_LENGTH), '#required' => TRUE, '#attributes' => array( 'autocorrect' => 'off', diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php index 99aaecb..9725c1f 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php @@ -8,6 +8,7 @@ namespace Drupal\user\Tests; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -106,12 +107,12 @@ function testValidation() { $this->assertEqual($violations[0]->getPropertyPath(), 'mail.0.value'); $this->assertEqual($violations[0]->getMessage(), t('This value is not a valid email address.')); - $mail = $this->randomName(EMAIL_MAX_LENGTH - 11) . '@example.com'; + $mail = $this->randomName(EmailItem::EMAIL_MAX_LENGTH - 11) . '@example.com'; $user->set('mail', $mail); $violations = $user->validate(); - $this->assertEqual(count($violations), 1, 'Violation found when email is too long'); + $this->assertEqual(count($violations), 2, 'Violation found when email is too long'); $this->assertEqual($violations[0]->getPropertyPath(), 'mail.0.value'); - $this->assertEqual($violations[0]->getMessage(), t('This value is not a valid email address.')); + $this->assertEqual($violations[0]->getMessage(), t('%name: the e-mail address can not be longer than @max characters.', array('%name' => $user->get('mail')->getFieldDefinition()->getFieldLabel(), '@max' => EmailItem::EMAIL_MAX_LENGTH))); // Provoke a e-mail collision with an exsiting user. $user->set('mail', 'existing@exmaple.com'); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 5751f02..eb417af 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -24,11 +24,6 @@ const USERNAME_MAX_LENGTH = 60; /** - * Maximum length of user e-mail text field. - */ -const EMAIL_MAX_LENGTH = 255; - -/** * Only administrators can create user accounts. */ const USER_REGISTER_ADMINISTRATORS_ONLY = 'admin_only';