function FileFieldTestBase::uploadNodeFile
Same name in this branch
- 8.9.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::uploadNodeFile()
Same name in other branches
- 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::uploadNodeFile()
- 10 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::uploadNodeFile()
- 11.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::uploadNodeFile()
Uploads a file to a node.
Parameters
\Drupal\file\FileInterface $file: The File to be uploaded.
string $field_name: The name of the field on which the files should be saved.
$nid_or_type: A numeric node id to upload files to an existing node, or a string indicating the desired bundle for a new node.
bool $new_revision: The revision number.
array $extras: Additional values when a new node is created.
Return value
int The node id.
File
-
core/
modules/ file/ src/ Tests/ FileFieldTestBase.php, line 173
Class
- FileFieldTestBase
- Provides methods specifically for testing File module's field handling.
Namespace
Drupal\file\TestsCode
public function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
return $this->uploadNodeFiles([
$file,
], $field_name, $nid_or_type, $new_revision, $extras);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.