1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Blitz PHP framework. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the LICENSE file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace BlitzPHP\Cli\Commands\Cache; |
13
|
|
|
|
14
|
|
|
use BlitzPHP\Cli\Console\Command; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Affiche des informations sur le cache. |
18
|
|
|
*/ |
19
|
|
|
class Info extends Command |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritDoc} |
23
|
|
|
*/ |
24
|
|
|
protected $group = 'Cache'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritDoc} |
28
|
|
|
*/ |
29
|
|
|
protected $name = 'cache:info'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritDoc} |
33
|
|
|
*/ |
34
|
|
|
protected $description = 'Affiche les informations du cache de fichiers dans le système actuel.'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritDoc} |
38
|
|
|
*/ |
39
|
|
|
protected $service = 'Service de mise en cache'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
*/ |
44
|
|
|
protected $arguments = [ |
45
|
|
|
'driver' => 'Le pilote de cache à utiliser', |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritDoc} |
50
|
|
|
*/ |
51
|
|
|
public function execute(array $params) |
52
|
|
|
{ |
53
|
|
|
$config = config('cache'); |
54
|
|
|
helper('number'); |
55
|
|
|
|
56
|
|
|
if ($config['handler'] !== 'file') { |
57
|
|
|
$this->fail('Cette commande ne prend en charge que le gestionnaire de cache de fichiers.'); |
58
|
|
|
|
59
|
|
|
return; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$cache = service('cache', $config); |
63
|
|
|
$caches = $cache->info(); |
64
|
|
|
$tbody = []; |
65
|
|
|
|
66
|
|
|
foreach ($caches as $key => $field) { |
67
|
|
|
$tbody[] = [ |
68
|
|
|
'nom' => $key, |
69
|
|
|
'chemin du serveur' => clean_path($field['server_path']), |
70
|
|
|
'taille' => number_to_size($field['size']), |
|
|
|
|
71
|
|
|
'date' => $field['date'], // @todo formatter avec Utilities\Date |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$this->table($tbody, ['head' => 'boldGreen']); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|