mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-07 10:54:03 +00:00
Change tenant storage listeners into jobs
Also move the commented jobs to the JobPipelines and update FilesystemTenancyBootstrapperTest accordingly.
This commit is contained in:
parent
c4960b76cb
commit
bf42a12894
5 changed files with 55 additions and 31 deletions
39
src/Jobs/CreateTenantStorage.php
Normal file
39
src/Jobs/CreateTenantStorage.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
/**
|
||||
* Can be used to manually create framework directories in the tenant storage when storage_path() is scoped.
|
||||
*
|
||||
* Useful when using real-time facades which use the framework/cache directory.
|
||||
*
|
||||
* Generally not needed anymore as the directory is also created by the FilesystemTenancyBootstrapper.
|
||||
*/
|
||||
class CreateTenantStorage implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$storage_path = tenancy()->run($this->tenant, fn () => storage_path());
|
||||
$cache_path = "$storage_path/framework/cache";
|
||||
|
||||
if (! is_dir($cache_path)) {
|
||||
// Create the tenant's storage directory and /framework/cache within (used for e.g. real-time facades)
|
||||
mkdir($cache_path, 0750, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue