Created
November 27, 2014 16:08
-
-
Save williamn/bdfb6ca11eddc0db628f to your computer and use it in GitHub Desktop.
CakePHP multitenant routing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Validates tenant | |
switch (isset($this->request->params['tenant'])) { | |
case true: | |
// The tennant should exist | |
$this->loadModel('Tenant'); | |
if ($this->Tenant->isExist($this->request->params['tenant']) == 0) { | |
throw new NotFoundException(); | |
} | |
break; | |
case false: | |
// On-premises mode | |
$this->redirect(array( | |
'tenant' => 'manually-set-customer-name' | |
)); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment