set order to desc for logs viewer
This commit is contained in:
parent
db313f5eef
commit
976e10659f
4 changed files with 21 additions and 3 deletions
|
|
@ -4,6 +4,8 @@ namespace MingTsay\Akanyan;
|
|||
|
||||
abstract class FileViewer
|
||||
{
|
||||
protected static bool $orderDesc = false;
|
||||
|
||||
protected abstract static function directory(): string;
|
||||
|
||||
protected abstract static function whitelist(): ?array;
|
||||
|
|
@ -13,10 +15,13 @@ abstract class FileViewer
|
|||
$directory = static::directory();
|
||||
$whitelist = static::whitelist();
|
||||
|
||||
return array_values(array_filter(
|
||||
$list = array_values(array_filter(
|
||||
scandir($directory),
|
||||
fn($file) => ($whitelist === null || in_array($file, $whitelist)) && is_file("$directory/$file")
|
||||
));
|
||||
|
||||
if (static::$orderDesc) rsort($list);
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function read($file): ?string
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace MingTsay\Akanyan;
|
|||
|
||||
class LogsViewer extends FileViewer
|
||||
{
|
||||
protected static bool $orderDesc = true;
|
||||
|
||||
protected static function directory(): string
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue