
| Current Path : /var/www/html/rocksensor1/web/core/modules/file/src/Upload/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor1/web/core/modules/file/src/Upload/FileUploadLocationTrait.php |
<?php
namespace Drupal\file\Upload;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\TypedData\FieldItemDataDefinition;
use Drupal\file\Plugin\Field\FieldType\FileFieldItemList;
use Drupal\file\Plugin\Field\FieldType\FileItem;
/**
* Resolves the file upload location from a file field definition.
*/
trait FileUploadLocationTrait {
/**
* Resolves the file upload location from a file field definition.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
* The file field definition.
*
* @return string
* An un-sanitized file directory URI with tokens replaced. The result of
* the token replacement is then converted to plain text and returned.
*/
public function getUploadLocation(FieldDefinitionInterface $fieldDefinition): string {
assert(is_a($fieldDefinition->getClass(), FileFieldItemList::class, TRUE));
$fieldItemDataDefinition = FieldItemDataDefinition::create($fieldDefinition);
$fileItem = new FileItem($fieldItemDataDefinition);
return $fileItem->getUploadLocation();
}
}