mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-24 13:44:42 +00:00
- Refactoring
- Download restriction
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
namespace App\Limitations;
|
||||
|
||||
use Illuminate\Support\Manager;
|
||||
use App\Limitations\Engines\DefaultLimitationEngine;
|
||||
use App\Limitations\Engines\FixedBillingLimitationEngine;
|
||||
use App\Limitations\Engines\MeteredBillingLimitationEngine;
|
||||
|
||||
class LimitationManager extends Manager
|
||||
{
|
||||
public function getDefaultDriver(): string
|
||||
{
|
||||
return get_limitation_driver();
|
||||
}
|
||||
|
||||
public function createDefaultDriver(): DefaultLimitationEngine
|
||||
{
|
||||
return new DefaultLimitationEngine();
|
||||
}
|
||||
|
||||
public function createFixedDriver(): FixedBillingLimitationEngine
|
||||
{
|
||||
return new FixedBillingLimitationEngine();
|
||||
}
|
||||
|
||||
public function createMeteredDriver(): MeteredBillingLimitationEngine
|
||||
{
|
||||
return new MeteredBillingLimitationEngine();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace App\Limitations\Engines;
|
||||
namespace App\Restrictions\Engines;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use App\Limitations\LimitationEngine;
|
||||
use App\Restrictions\RestrictionsEngine;
|
||||
use Domain\Teams\Actions\CheckMaxTeamMembersLimitAction;
|
||||
|
||||
class DefaultLimitationEngine implements LimitationEngine
|
||||
class DefaultRestrictionsEngine implements RestrictionsEngine
|
||||
{
|
||||
public function canUpload(User $user, int $fileSize = 0): bool
|
||||
{
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace App\Limitations\Engines;
|
||||
namespace App\Restrictions\Engines;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use App\Limitations\LimitationEngine;
|
||||
use App\Restrictions\RestrictionsEngine;
|
||||
use Domain\Teams\Actions\CheckMaxTeamMembersLimitAction;
|
||||
|
||||
class FixedBillingLimitationEngine implements LimitationEngine
|
||||
class FixedBillingRestrictionsEngine implements RestrictionsEngine
|
||||
{
|
||||
public function canUpload(User $user, int $fileSize = 0): bool
|
||||
{
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Limitations\Engines;
|
||||
namespace App\Restrictions\Engines;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use App\Limitations\LimitationEngine;
|
||||
use App\Restrictions\RestrictionsEngine;
|
||||
|
||||
class MeteredBillingLimitationEngine implements LimitationEngine
|
||||
class MeteredBillingRestrictionsEngine implements RestrictionsEngine
|
||||
{
|
||||
public function canUpload(User $user, int $fileSize = 0): bool
|
||||
{
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Limitations;
|
||||
namespace App\Restrictions;
|
||||
|
||||
use App\Users\Models\User;
|
||||
|
||||
interface LimitationEngine
|
||||
interface RestrictionsEngine
|
||||
{
|
||||
public function canUpload(User $user, int $fileSize = 0): bool;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace App\Restrictions;
|
||||
|
||||
use Illuminate\Support\Manager;
|
||||
use App\Restrictions\Engines\DefaultRestrictionsEngine;
|
||||
use App\Restrictions\Engines\FixedBillingRestrictionsEngine;
|
||||
use App\Restrictions\Engines\MeteredBillingRestrictionsEngine;
|
||||
|
||||
class RestrictionsManager extends Manager
|
||||
{
|
||||
public function getDefaultDriver(): string
|
||||
{
|
||||
return get_restriction_driver();
|
||||
}
|
||||
|
||||
public function createDefaultDriver(): DefaultRestrictionsEngine
|
||||
{
|
||||
return new DefaultRestrictionsEngine();
|
||||
}
|
||||
|
||||
public function createFixedDriver(): FixedBillingRestrictionsEngine
|
||||
{
|
||||
return new FixedBillingRestrictionsEngine();
|
||||
}
|
||||
|
||||
public function createMeteredDriver(): MeteredBillingRestrictionsEngine
|
||||
{
|
||||
return new MeteredBillingRestrictionsEngine();
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,9 @@ use Illuminate\Support\Facades\DB;
|
||||
use Database\Factories\UserFactory;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use App\Limitations\LimitationManager;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use App\Restrictions\RestrictionsManager;
|
||||
use App\Users\Notifications\ResetPassword;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
@@ -203,7 +203,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (str_starts_with($method, 'can')) {
|
||||
return resolve(LimitationManager::class)
|
||||
return resolve(RestrictionsManager::class)
|
||||
->driver()
|
||||
->$method($this, ...$parameters);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user