Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix: APP_TENANT_ID can be set to false in the .env to short-cercuit t…
Browse files Browse the repository at this point in the history
…he custom uploads directory behavior.
  • Loading branch information
devuri committed Feb 14, 2024
1 parent 6d1fdae commit 66763cc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/App/Core/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ public function __construct()
// define basic app settings
$this->define_basic_app_init();

// set a tenant ID.
$this->tenant_id = env_tenant_id() ?? md5(APP_HTTP_HOST);
/**
* The tenant ID for the application.
*
* This sets the tenant ID based on the environment configuration. The `APP_TENANT_ID`
* can be configured in the `.env` file. Setting `APP_TENANT_ID` to false will disable the
* custom uploads directory behavior that is typically used in a multi-tenant setup. In a
* multi-tenant environment, `APP_TENANT_ID` is required and must always be set. The method
* uses `env_tenant_id()` function to retrieve the tenant ID from the environment settings.
*/
$this->tenant_id = env_tenant_id();

new WhiteLabel();

Expand Down Expand Up @@ -67,7 +75,9 @@ function() {
);

// separate uploads for multi tenant.
add_filter( 'upload_dir', [ $this, 'set_upload_directory' ] );
if( ! is_null( $this->tenant_id ) || false !== $this->tenant_id ) {
add_filter( 'upload_dir', [ $this, 'set_upload_directory' ] );
}

// multi tenant setup for plugins.
if ( defined( 'ALLOW_MULTITENANT' ) && ALLOW_MULTITENANT === true ) {
Expand Down

0 comments on commit 66763cc

Please sign in to comment.