mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 20:54:03 +00:00
wip
This commit is contained in:
parent
d0d1f6930b
commit
7a96ff1e66
5 changed files with 49 additions and 2 deletions
|
|
@ -40,7 +40,8 @@
|
||||||
"Stancl\\Tenancy\\TenancyServiceProvider"
|
"Stancl\\Tenancy\\TenancyServiceProvider"
|
||||||
],
|
],
|
||||||
"aliases": {
|
"aliases": {
|
||||||
"Tenancy": "Stancl\\Tenancy\\TenancyFacade"
|
"Tenancy": "Stancl\\Tenancy\\TenancyFacade",
|
||||||
|
"GlobalCache": "Stancl\\Tenancy\\GlobalCacheFacade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
13
src/GlobalCacheFacade.php
Normal file
13
src/GlobalCacheFacade.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class GlobalCacheFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'globalCache';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,7 @@ use Illuminate\Support\ServiceProvider;
|
||||||
use Stancl\Tenancy\Commands\TenantList;
|
use Stancl\Tenancy\Commands\TenantList;
|
||||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||||
use Stancl\Tenancy\Interfaces\ServerConfigManager;
|
use Stancl\Tenancy\Interfaces\ServerConfigManager;
|
||||||
|
use Illuminate\Cache\CacheManager;
|
||||||
|
|
||||||
class TenancyServiceProvider extends ServiceProvider
|
class TenancyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
@ -69,5 +70,9 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
$this->app->singleton(Seed::class, function ($app) {
|
$this->app->singleton(Seed::class, function ($app) {
|
||||||
return new Seed($app['db'], $app[DatabaseManager::class]);
|
return new Seed($app['db'], $app[DatabaseManager::class]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->app->bind('globalCache', function ($app) {
|
||||||
|
return new CacheManager($app);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
tests/GlobalCacheTest.php
Normal file
27
tests/GlobalCacheTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
|
use GlobalCache;
|
||||||
|
|
||||||
|
class GlobalCacheTest extends TestCase
|
||||||
|
{
|
||||||
|
public $autoCreateTenant = false;
|
||||||
|
public $autoInitTenancy = false;
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function global_cache_manager_stores_data_in_global_cache()
|
||||||
|
{
|
||||||
|
dd(app('globalCache'));
|
||||||
|
dd(cache());
|
||||||
|
$this->assertSame(null, cache('foo'));
|
||||||
|
cache(['foo' => 'bar'], 1);
|
||||||
|
$this->assertSame('bar', cache('foo'));
|
||||||
|
// $this->assertSame('bar', GlobalCache::get('foo'));
|
||||||
|
// GlobalCache::put('foo', 'bar');
|
||||||
|
dd(GlobalCache::get('foo'));
|
||||||
|
|
||||||
|
tenant()->create('foo.localhost');
|
||||||
|
tenancy()->init('foo.localhost');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -98,7 +98,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
protected function getPackageAliases($app)
|
protected function getPackageAliases($app)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Tenancy' => \Stancl\Tenancy\TenancyFacade::class
|
'Tenancy' => \Stancl\Tenancy\TenancyFacade::class,
|
||||||
|
'GlobalCache' => \Stancl\Tenancy\GlobalCacheFacade::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue