function FileFieldTestBase::getLastFileId

Same name in this branch
  1. 8.9.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()
Same name in other branches
  1. 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()
  2. 10 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()
  3. 11.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()

Retrieves the fid of the last inserted file.

File

core/modules/file/src/Tests/FileFieldTestBase.php, line 62

Class

FileFieldTestBase
Provides methods specifically for testing File module's field handling.

Namespace

Drupal\file\Tests

Code

public function getLastFileId() {
    return (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')
        ->execute()[0]['fid_max'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.