trait InfoWriterTrait
Writes the info file and ensures the mtime changes.
Hierarchy
- trait \Drupal\TestTools\Extension\InfoWriterTrait
 
See also
\Drupal\Component\FileCache\FileCache
\Drupal\Core\Extension\InfoParser
3 files declare their use of InfoWriterTrait
- ModulesListFormWebTest.php in core/
modules/ system/ tests/ src/ Functional/ Form/ ModulesListFormWebTest.php  - ThemeUiTest.php in core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeUiTest.php  - UpdateScriptTest.php in core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ UpdateScriptTest.php  
File
- 
              core/
tests/ Drupal/ TestTools/ Extension/ InfoWriterTrait.php, line 15  
Namespace
Drupal\TestTools\ExtensionView source
trait InfoWriterTrait {
  
  /**
   * Writes the info file and ensures the mtime changes.
   *
   * @param string $file_path
   *   The info file path.
   * @param array $info
   *   The info array.
   *
   * @return void
   */
  private function writeInfoFile(string $file_path, array $info) : void {
    $mtime = file_exists($file_path) ? filemtime($file_path) : FALSE;
    file_put_contents($file_path, Yaml::encode($info));
    // Ensure mtime changes.
    if ($mtime === filemtime($file_path)) {
      touch($file_path, max($mtime + 1, time()));
    }
  }
}
Members
| Title Sort descending | Modifiers | Object type | Summary | 
|---|---|---|---|
| InfoWriterTrait::writeInfoFile | private | function | Writes the info file and ensures the mtime changes. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.