configuration improvements (#1784)
This commit is contained in:
@@ -18,7 +18,7 @@ class AvatarService
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $projectDirectory;
|
||||
private $directory;
|
||||
|
||||
public const AVATAR_CONFIG = [
|
||||
'driver' => 'gd',
|
||||
@@ -105,7 +105,17 @@ class AvatarService
|
||||
|
||||
public function __construct(string $projectDirectory)
|
||||
{
|
||||
$this->projectDirectory = $projectDirectory;
|
||||
$this->setStorageDirectory($projectDirectory . '/public/avatars/');
|
||||
}
|
||||
|
||||
public function getStorageDirectory(): string
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
public function setStorageDirectory(string $directory)
|
||||
{
|
||||
$this->directory = realpath($directory);
|
||||
}
|
||||
|
||||
private function getAvatarUrl(User $profile): string
|
||||
@@ -115,9 +125,7 @@ class AvatarService
|
||||
|
||||
private function getImagePath(User $profile): string
|
||||
{
|
||||
$avatarPath = realpath($this->projectDirectory . '/public/avatars/');
|
||||
|
||||
return $avatarPath . '/' . $this->getAvatarUrl($profile);
|
||||
return $this->getStorageDirectory() . '/' . $this->getAvatarUrl($profile);
|
||||
}
|
||||
|
||||
public function generateAvatar(User $profile, bool $regenerate = false): bool
|
||||
|
||||
@@ -28,6 +28,11 @@ final class FileHelper
|
||||
$this->filesystem = new Filesystem();
|
||||
}
|
||||
|
||||
public function setDataDirectory(string $directory)
|
||||
{
|
||||
$this->dataDir = $directory;
|
||||
}
|
||||
|
||||
public function getDataDirectory(string $subDirectory = null): string
|
||||
{
|
||||
$directory = $this->dataDir . '/';
|
||||
|
||||
Reference in New Issue
Block a user