
| Current Path : /var/www/html/stolberg/web/core/tests/Drupal/TestTools/Extension/ |
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/stolberg/web/core/tests/Drupal/TestTools/Extension/InfoWriterTrait.php |
<?php
declare(strict_types=1);
namespace Drupal\TestTools\Extension;
use Drupal\Core\Serialization\Yaml;
/**
* Writes the info file and ensures the mtime changes.
*
* @see \Drupal\Component\FileCache\FileCache
* @see \Drupal\Core\Extension\InfoParser
*/
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()));
}
}
}