1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 15:54:03 +00:00

disable new jobs/listeners by default, add CreateTenantStorage job

This commit is contained in:
Samuel Štancl 2022-12-02 19:43:20 +01:00
parent 45aac1a718
commit a7ad8287e6
3 changed files with 26 additions and 3 deletions

View file

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Listeners;
use Stancl\Tenancy\Events\TenantCreated;
class CreateTenantStorage
{
public function handle(TenantCreated $event): void
{
$storage_path = $event->tenant->run(fn () => storage_path());
mkdir("$storage_path", 0777, true); // Create the tenant's folder inside storage/
mkdir("$storage_path/framework/cache", 0777, true); // Create /framework/cache inside the tenant's storage (used for e.g. real-time facades)
}
}

View file

@ -11,6 +11,9 @@ class DeleteTenantStorage
{
public function handle(DeletingTenant $event): void
{
// todo@lukas since this is using the 'File' facade instead of low-level PHP functions, Tenancy might affect this?
// Therefore, when Tenancy is initialized, this might look INSIDE the tenant's storage, instead of the main storage dir?
// The DeletingTenant event will be fired in the central context in 99% of cases, but sometimes it might run in the tenant context (from another tenant) so we want to make sure this works well in all contexts.
File::deleteDirectory($event->tenant->run(fn () => storage_path()));
}
}