Final Class Yiisoft\Yii\Debug\Storage\FileStorage
| Inheritance | Yiisoft\Yii\Debug\Storage\FileStorage |
|---|---|
| Implements | Yiisoft\Yii\Debug\Storage\StorageInterface |
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TYPE_DATA | 'data' | Yiisoft\Yii\Debug\Storage\StorageInterface | |
| TYPE_OBJECTS | 'objects' | Yiisoft\Yii\Debug\Storage\StorageInterface | |
| TYPE_SUMMARY | 'summary' | Yiisoft\Yii\Debug\Storage\StorageInterface |
Method Details
| public mixed __construct ( string $path ) | ||
| $path | string | |
public function __construct(
private readonly string $path,
) {
}
| public array read ( string $type, string|null $id = null ) | ||
| $type | string | |
| $id | string|null | |
public function read(string $type, ?string $id = null): array
{
clearstatcache();
$dataFiles = $this->findFilesOrderedByModifiedTime(
sprintf(
'%s/**/%s/%s.json',
$this->path,
$id ?? '**',
$type,
)
);
$data = [];
foreach ($dataFiles as $file) {
$dir = dirname($file);
$id = substr($dir, strlen(dirname($file, 2)) + 1);
$content = file_get_contents($file);
$data[$id] = $content === '' ? '' : json_decode($content, true, flags: JSON_THROW_ON_ERROR);
}
return $data;
}
| public void setHistorySize ( integer $historySize ) | ||
| $historySize | integer | |
public function setHistorySize(int $historySize): void
{
$this->historySize = $historySize;
}
| public void write ( string $id, array $data, array $objectsMap, array $summary ) | ||
| $id | string | |
| $data | array | |
| $objectsMap | array | |
| $summary | array | |
public function write(string $id, array $data, array $objectsMap, array $summary): void
{
$basePath = $this->path . '/' . date('Y-m-d') . '/' . $id . '/';
try {
FileHelper::ensureDirectory($basePath);
file_put_contents($basePath . self::TYPE_DATA . '.json', $this->encode($data));
file_put_contents($basePath . self::TYPE_OBJECTS . '.json', $this->encode($objectsMap));
file_put_contents($basePath . self::TYPE_SUMMARY . '.json', $this->encode($summary));
} finally {
$this->gc();
}
}
Signup or Login in order to comment.