|
3 | 3 | namespace ProcessMaker; |
4 | 4 |
|
5 | 5 | use Igaster\LaravelTheme\Facades\Theme; |
| 6 | +use Illuminate\Filesystem\Filesystem; |
6 | 7 | use Illuminate\Foundation\Application as IlluminateApplication; |
| 8 | +use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables; |
| 9 | +use Illuminate\Foundation\Bootstrap\RegisterProviders; |
| 10 | +use Illuminate\Foundation\PackageManifest; |
| 11 | +use Illuminate\Support\Env; |
| 12 | +use Illuminate\Support\Facades\App; |
7 | 13 | use Illuminate\Support\Facades\Auth; |
| 14 | +use Illuminate\Support\Facades\Config; |
| 15 | +use ProcessMaker\Multitenancy\Tenant; |
| 16 | +use ProcessMaker\Multitenancy\TenantBootstrapper; |
8 | 17 |
|
9 | 18 | /** |
10 | 19 | * Class Application. |
11 | 20 | */ |
12 | 21 | class Application extends IlluminateApplication |
13 | 22 | { |
| 23 | + public $overrideTenantId = null; |
| 24 | + |
| 25 | + public $skipCacheEvents = false; |
| 26 | + |
14 | 27 | /** |
15 | 28 | * Sets the timezone for the application and for php with the specified timezone. |
16 | 29 | * |
@@ -78,13 +91,25 @@ public function path($path = '') |
78 | 91 | return $this->basePath . DIRECTORY_SEPARATOR . 'ProcessMaker' . ($path ? DIRECTORY_SEPARATOR . $path : $path); |
79 | 92 | } |
80 | 93 |
|
81 | | - public function setStoragePath($path) |
| 94 | + public function registerConfiguredProviders() |
82 | 95 | { |
83 | | - $this->storagePath = $path; |
| 96 | + // Must be rebound before registerConfiguredProviders() runs but after bootstrapping is done |
| 97 | + // so we can access storage and cache facades. |
| 98 | + $this->singleton(PackageManifest::class, fn () => new LicensedPackageManifest( |
| 99 | + new Filesystem, $this->basePath(), $this->getCachedPackagesPath() |
| 100 | + )); |
| 101 | + |
| 102 | + parent::registerConfiguredProviders(); |
84 | 103 | } |
85 | 104 |
|
86 | | - public function getStoragePath() |
| 105 | + public function bootstrapWith(array $bootstrappers) |
87 | 106 | { |
88 | | - return $this->storagePath; |
| 107 | + // Insert TenantBootstrapper after LoadEnvironmentVariables |
| 108 | + if ($bootstrappers[0] !== LoadEnvironmentVariables::class) { |
| 109 | + throw new \Exception('LoadEnvironmentVariables is not the first bootstrapper. Did a laravel upgrade change this?'); |
| 110 | + } |
| 111 | + array_splice($bootstrappers, 1, 0, [TenantBootstrapper::class]); |
| 112 | + |
| 113 | + return parent::bootstrapWith($bootstrappers); |
89 | 114 | } |
90 | 115 | } |
0 commit comments