diff --git a/core/modules/field/field.tokens.inc b/core/modules/field/field.tokens.inc deleted file mode 100644 index 41c66ab..0000000 --- a/core/modules/field/field.tokens.inc +++ /dev/null @@ -1,50 +0,0 @@ - [ - 'field-storage' => [ - 'name' => t('Field storage'), - 'description' => t('Tokens related to field storage items.'), - 'needs-data' => 'field-storage', - ], - ], - 'tokens' => [ - 'field-storage' => [ - 'name' => [ - 'name' => t('Field name'), - 'description' => t('Machine name of the field.'), - ], - ], - ], - ]; -} - -/** - * Implements hook_tokens(). - */ -function field_tokens($type, $tokens, array $data = array(), array $options = array()) { - $replacements = []; - - if ($type == 'field-storage' && !empty($data['field-storage'])) { - /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage */ - $field_storage = $data['field-storage']; - - foreach ($tokens as $name => $original) { - switch ($name) { - case 'name': - $replacements[$original] = $field_storage->getName(); - break; - } - } - } - - return $replacements; -} diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 419c733..57ae945 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -51,7 +51,7 @@ public static function defaultStorageSettings() { public static function defaultFieldSettings() { return array( 'file_extensions' => 'txt', - 'file_directory' => '[field-storage:name]/[date:custom:Y]-[date:custom:m]', + 'file_directory' => '[date:custom:Y]-[date:custom:m]', 'max_filesize' => '', 'description_field' => 0, ) + parent::defaultFieldSettings(); @@ -270,8 +270,8 @@ public function getUploadLocation($data = array()) { $settings = $this->getSettings(); $destination = trim($settings['file_directory'], '/'); - $data += ['field-storage' => $this->getFieldDefinition()->getFieldStorageDefinition()]; - // Replace tokens. As the tokens might contain HTML we convert to plaintext. + // Replace tokens. As the tokens might contain HTML we convert it to plain + // text. $destination = PlainTextOutput::renderFromHtml(\Drupal::token()->replace($destination, $data)); return $settings['uri_scheme'] . '://' . $destination; } @@ -313,7 +313,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin // Prepare destination. $dirname = $settings['uri_scheme'] . '://' . $settings['file_directory']; - $dirname = \Drupal::token()->replace($dirname, ['field-storage' => $field_definition->getFieldStorageDefinition()]); + $dirname = \Drupal::token()->replace($dirname); file_prepare_directory($dirname, FILE_CREATE_DIRECTORY); // Generate a file entity. diff --git a/core/modules/file/src/Tests/FileFieldPathTest.php b/core/modules/file/src/Tests/FileFieldPathTest.php index d178858..acafd4b 100644 --- a/core/modules/file/src/Tests/FileFieldPathTest.php +++ b/core/modules/file/src/Tests/FileFieldPathTest.php @@ -38,7 +38,6 @@ function testUploadPath() { $date_formatter = $this->container->get('date.formatter'); $expected_filename = 'public://' . - $field_name . '/' . $date_formatter->format(REQUEST_TIME, 'custom', 'Y') . '-' . $date_formatter->format(REQUEST_TIME, 'custom', 'm') . '/' . $test_file->getFilename(); diff --git a/core/profiles/standard/config/install/field.field.node.article.field_image.yml b/core/profiles/standard/config/install/field.field.node.article.field_image.yml index 1169dde..b4b1c14 100644 --- a/core/profiles/standard/config/install/field.field.node.article.field_image.yml +++ b/core/profiles/standard/config/install/field.field.node.article.field_image.yml @@ -17,7 +17,7 @@ translatable: true default_value: { } default_value_callback: '' settings: - file_directory: '[field-storage:name]/[date:custom:Y]-[date:custom:m]' + file_directory: '[date:custom:Y]-[date:custom:m]' file_extensions: 'png gif jpg jpeg' max_filesize: '' max_resolution: '' diff --git a/core/profiles/standard/config/install/field.field.user.user.user_picture.yml b/core/profiles/standard/config/install/field.field.user.user.user_picture.yml index 014b0f8..5922204 100644 --- a/core/profiles/standard/config/install/field.field.user.user.user_picture.yml +++ b/core/profiles/standard/config/install/field.field.user.user.user_picture.yml @@ -18,7 +18,7 @@ default_value: { } default_value_callback: '' settings: file_extensions: 'png gif jpg jpeg' - file_directory: '[field-storage:name]/[date:custom:Y]-[date:custom:m]' + file_directory: '[date:custom:Y]-[date:custom:m]' max_filesize: '30 KB' alt_field: false title_field: false