mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
file manager change
This commit is contained in:
@@ -139,7 +139,9 @@ class ContainerBuilder
|
||||
);
|
||||
|
||||
$fileManager = $this->services['fileManager'] ?? (
|
||||
new $this->fileManagerClassName($config)
|
||||
new $this->fileManagerClassName(
|
||||
$config->get('defaultPermissions')
|
||||
)
|
||||
);
|
||||
|
||||
$dataCache = $this->services['dataCache'] ?? (
|
||||
|
||||
@@ -45,11 +45,21 @@ class EspoFileHandler extends MonologStreamHandler
|
||||
|
||||
protected $maxErrorMessageLength = 5000;
|
||||
|
||||
protected $configPath = 'data/config.php';
|
||||
|
||||
public function __construct(string $filename, $level = Logger::DEBUG, bool $bubble = true)
|
||||
{
|
||||
parent::__construct($filename, $level, $bubble);
|
||||
|
||||
$this->fileManager = new FileManager();
|
||||
$defaultPermissions = null;
|
||||
|
||||
if (file_exists($this->configPath)) {
|
||||
$configData = include $this->configPath;
|
||||
|
||||
$defaultPermissions = $configData['defaultPermissions'] ?? null;
|
||||
}
|
||||
|
||||
$this->fileManager = new FileManager($defaultPermissions);
|
||||
}
|
||||
|
||||
protected function write(array $record): void
|
||||
|
||||
@@ -45,7 +45,9 @@ class ConfigFileManager
|
||||
|
||||
public function setConfig(Config $config)
|
||||
{
|
||||
$this->fileManager = new FileManager($config);
|
||||
$this->fileManager = new FileManager(
|
||||
$config->get('defaultPermissions')
|
||||
);
|
||||
}
|
||||
|
||||
public function isFile(string $filePath) : bool
|
||||
|
||||
@@ -55,13 +55,13 @@ class Manager
|
||||
|
||||
const GET_SAFE_CONTENTS_RETRY_INTERVAL = 0.1;
|
||||
|
||||
public function __construct(?Config $config = null)
|
||||
public function __construct(?array $defaultPermissions = null)
|
||||
{
|
||||
$params = null;
|
||||
|
||||
if (isset($config)) {
|
||||
if ($defaultPermissions) {
|
||||
$params = [
|
||||
'defaultPermissions' => $config->get('defaultPermissions'),
|
||||
'defaultPermissions' => $defaultPermissions,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@
|
||||
************************************************************************/
|
||||
|
||||
namespace tests\unit\Espo\Core\Utils\File;
|
||||
|
||||
use tests\unit\ReflectionHelper;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
class ManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
@@ -44,9 +47,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->objects['config'] = $this->getMockBuilder('\Espo\Core\Utils\Config')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->object = new \Espo\Core\Utils\File\Manager();
|
||||
$this->object = new FileManager();
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->object);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user