function editor_test_file_presave
Same name in other branches
- 9 core/modules/editor/tests/modules/editor_test/editor_test.module \editor_test_file_presave()
- 8.9.x core/modules/editor/tests/modules/editor_test.module \editor_test_file_presave()
- 10 core/modules/editor/tests/modules/editor_test/editor_test.module \editor_test_file_presave()
Implements hook_ENTITY_TYPE_presave() for file entities.
File
-
core/
modules/ editor/ tests/ modules/ editor_test/ editor_test.module, line 90
Code
function editor_test_file_presave(FileInterface $file) {
// Use state to keep track of how many times a file is saved.
$file_save_count = \Drupal::state()->get('editor_test.file_save_count', []);
$file_save_count[$file->getFilename()] = isset($file_save_count[$file->getFilename()]) ? $file_save_count[$file->getFilename()] + 1 : 1;
\Drupal::state()->set('editor_test.file_save_count', $file_save_count);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.