comparison core/modules/field/src/Entity/FieldStorageConfig.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\field\Entity; 3 namespace Drupal\field\Entity;
4 4
5 use Drupal\Component\Utility\Unicode;
6 use Drupal\Core\Config\Entity\ConfigEntityBase; 5 use Drupal\Core\Config\Entity\ConfigEntityBase;
7 use Drupal\Core\Entity\EntityStorageInterface; 6 use Drupal\Core\Entity\EntityStorageInterface;
8 use Drupal\Core\Entity\FieldableEntityInterface; 7 use Drupal\Core\Entity\FieldableEntityInterface;
9 use Drupal\Core\Entity\FieldableEntityStorageInterface; 8 use Drupal\Core\Entity\FieldableEntityStorageInterface;
10 use Drupal\Core\Field\FieldException; 9 use Drupal\Core\Field\FieldException;
16 * Defines the Field storage configuration entity. 15 * Defines the Field storage configuration entity.
17 * 16 *
18 * @ConfigEntityType( 17 * @ConfigEntityType(
19 * id = "field_storage_config", 18 * id = "field_storage_config",
20 * label = @Translation("Field storage"), 19 * label = @Translation("Field storage"),
20 * label_collection = @Translation("Field storages"),
21 * label_singular = @Translation("field storage"),
22 * label_plural = @Translation("field storages"),
23 * label_count = @PluralTranslation(
24 * singular = "@count field storage",
25 * plural = "@count field storages",
26 * ),
21 * handlers = { 27 * handlers = {
22 * "access" = "Drupal\field\FieldStorageConfigAccessControlHandler", 28 * "access" = "Drupal\field\FieldStorageConfigAccessControlHandler",
23 * "storage" = "Drupal\field\FieldStorageConfigStorage" 29 * "storage" = "Drupal\field\FieldStorageConfigStorage"
24 * }, 30 * },
25 * config_prefix = "storage", 31 * config_prefix = "storage",
308 $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); 314 $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
309 315
310 // Assign the ID. 316 // Assign the ID.
311 $this->id = $this->id(); 317 $this->id = $this->id();
312 318
313 // Field name cannot be longer than FieldStorageConfig::NAME_MAX_LENGTH characters. 319 // Field name cannot be longer than FieldStorageConfig::NAME_MAX_LENGTH
314 // We use Unicode::strlen() because the DB layer assumes that column widths 320 // characters. We use mb_strlen() because the DB layer assumes that column
315 // are given in characters rather than bytes. 321 // widths are given in characters rather than bytes.
316 if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) { 322 if (mb_strlen($this->getName()) > static::NAME_MAX_LENGTH) {
317 throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName()); 323 throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName());
318 } 324 }
319 325
320 // Disallow reserved field names. 326 // Disallow reserved field names.
321 $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId())); 327 $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));