Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public function __invoke($request, $response, $next)
  2. {
  3. $response = $next($request, $response);
  4. $tenantMap = TableRegistry::get('TenantMappings');
  5. $mapping = $tenantMap->findByName($request->subdomains()[0])->firstOrFail();
  6. ConnectionManager::config("alias_".$request->subdomains()[0], [
  7. 'className' => 'CakeDatabaseConnection',
  8. 'driver' => 'CakeDatabaseDriverMysql',
  9. 'persistent' => false,
  10. 'host' => 'localhost',
  11. 'username' => '***username***',
  12. 'password' => '***password***',
  13. 'database' => '***database***',
  14. 'encoding' => 'utf8',
  15. 'timezone' => 'UTC',
  16. 'cacheMetadata' => true,
  17. ]);
  18. ConnectionManager::alias ("alias_".$request->subdomains()[0], "default");
  19. Configure::write('Account.active', $mapping->account_id);
  20.  
  21.  
  22. return $response;
  23. }
Add Comment
Please, Sign In to add comment