mirror of
https://github.com/filegator/filegator.git
synced 2025-08-05 22:37:41 +02:00
Read a fill current permissions for local driver Finished permissions for ftp driver, read and change Read permissions for sftp adapter Created FilegatorFtp for a cleaner permissions integration Implemented recursive chmod options for files/folders Modified tests to cover permissions Lint frontend permissions component
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the FileGator package.
|
|
*
|
|
* (c) Milos Stojanovic <alcalbg@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE file
|
|
*/
|
|
|
|
namespace Filegator\Services\Storage;
|
|
|
|
use Filegator\Utils\Collection;
|
|
|
|
class DirectoryCollection implements \JsonSerializable
|
|
{
|
|
use Collection;
|
|
|
|
protected $location;
|
|
|
|
public function __construct($location)
|
|
{
|
|
$this->location = $location;
|
|
}
|
|
|
|
public function addFile(string $type, string $path, string $name, int $size, int $timestamp, int $permissions)
|
|
{
|
|
if (! in_array($type, ['dir', 'file', 'back'])) {
|
|
throw new \Exception('Invalid file type.');
|
|
}
|
|
|
|
$this->add([
|
|
'type' => $type,
|
|
'path' => $path,
|
|
'name' => $name,
|
|
'size' => $size,
|
|
'time' => $timestamp,
|
|
'permissions' => $permissions,
|
|
]);
|
|
}
|
|
|
|
public function resetTimestamps($timestamp = 0)
|
|
{
|
|
foreach ($this->items as &$item) {
|
|
$item['time'] = $timestamp;
|
|
}
|
|
}
|
|
|
|
public function jsonSerialize()
|
|
{
|
|
$this->sortByValue('type');
|
|
|
|
return [
|
|
'location' => $this->location,
|
|
'files' => $this->items,
|
|
];
|
|
}
|
|
}
|