1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:34:04 +00:00

Specify namespace on global functions (fix #35) (#36)

* Specify namespace on global functions (fix #35)

* merge

* Revert some \ additions

* small fixes
This commit is contained in:
Samuel Štancl 2019-04-24 17:33:41 +02:00 committed by GitHub
parent 35abb6191d
commit 97ec172fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 12 deletions

View file

@ -11,7 +11,7 @@ class CacheManager extends BaseCacheManager
$tags = [config('tenancy.cache.tag_base') . tenant('uuid')];
if ($method === "tags") {
if (count($parameters) !== 1) {
if (\count($parameters) !== 1) {
throw new \Exception("Method tags() takes exactly 1 argument. {count($parameters)} passed.");
}

View file

@ -2,7 +2,6 @@
namespace Stancl\Tenancy;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseCreator;
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseDeleter;
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;

View file

@ -12,7 +12,6 @@ use Illuminate\Support\ServiceProvider;
use Stancl\Tenancy\Commands\TenantList;
use Stancl\Tenancy\Interfaces\StorageDriver;
use Stancl\Tenancy\Interfaces\ServerConfigManager;
use Stancl\Tenancy\StorageDrivers\RedisStorageDriver;
class TenancyServiceProvider extends ServiceProvider
{

View file

@ -2,7 +2,6 @@
namespace Stancl\Tenancy;
use Illuminate\Support\Facades\Redis;
use Stancl\Tenancy\Interfaces\StorageDriver;
use Stancl\Tenancy\Traits\BootstrapsTenancy;
use Illuminate\Contracts\Foundation\Application;
@ -166,7 +165,7 @@ class TenantManager
public function getDatabaseName($tenant = []): string
{
$tenant = $tenant ?: $this->tenant;
return config('tenancy.database.prefix') . $tenant['uuid'] . config('tenancy.database.suffix');
return $this->app['config']['tenancy.database.prefix'] . $tenant['uuid'] . $this->app['config']['tenancy.database.suffix'];
}
/**
@ -233,7 +232,7 @@ class TenantManager
{
$uuid = $uuid ?: $this->tenant['uuid'];
if (is_array($key)) {
if (\is_array($key)) {
return $this->jsonDecodeArrayValues($this->storage->getMany($uuid, $key));
}
@ -250,7 +249,7 @@ class TenantManager
*/
public function put($key, $value = null, string $uuid = null)
{
if (is_null($uuid)) {
if (\is_null($uuid)) {
if (! isset($this->tenant['uuid'])) {
throw new \Exception("No UUID supplied (and no tenant is currently identified).");
}
@ -264,11 +263,11 @@ class TenantManager
$target = []; // black hole
}
if (! is_null($value)) {
if (! \is_null($value)) {
return $target[$key] = json_decode($this->storage->put($uuid, $key, json_encode($value)), true);
}
if (! is_array($key)) {
if (! \is_array($key)) {
throw new \Exception("No value supplied for key $key.");
}
@ -310,7 +309,7 @@ class TenantManager
*/
public function __invoke($attribute)
{
if (is_null($attribute)) {
if (\is_null($attribute)) {
return $this->tenant;
}

View file

@ -9,7 +9,7 @@ class TenantRouteServiceProvider extends RouteServiceProvider
{
public function map()
{
if (! in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? [])
if (! \in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? [])
&& file_exists(base_path('routes/tenant.php'))) {
Route::middleware(['web', 'tenancy'])
->namespace($this->app['config']['tenant_route_namespace'] ?? 'App\Http\Controllers')

View file

@ -26,7 +26,7 @@ trait BootstrapsTenancy
public function setPhpRedisPrefix($connections = ['default'])
{
foreach ($connections as $connection) {
$prefix = config('tenancy.redis.prefix_base') . $this->tenant['uuid'];
$prefix = $this->app['config']['tenancy.redis.prefix_base'] . $this->tenant['uuid'];
$client = Redis::connection($connection)->client();
$client->setOption($client::OPT_PREFIX, $prefix);
}