Created
June 21, 2014 23:04
-
-
Save francisrod01/fdbdf99a20c53d1354ad to your computer and use it in GitHub Desktop.
CakePHP 2.4 - Carrego um controller para o administrator com new Controller()
This file contains 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
App::import('Controller', 'Users'); | |
App::import('Controller', 'Business'); | |
class AdministratorController extends AppController { | |
public function panel_profile() { | |
switch ($this->userDataGroupID) { | |
// Case Group is Developer's | |
case 1 : | |
$Users = new UsersController; | |
$Users->dev_profile(); | |
break; | |
// Case Group is Administrator's | |
case 2 : | |
$Users = new UsersController; | |
$Users->panel_profile(); | |
break; | |
// Case Group is Business | |
case 5 : | |
$Business = new BusinessController; | |
$Business->panel_profile(); | |
break; | |
// Case not group | |
default : | |
$Users = new UsersController; | |
$Users->logout(); | |
} | |
} | |
... | |
} |
This file contains 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
// function in AppController() -> __afterRender() | |
if (isset(Router::getParams()['prefix'])) | |
if (is_array($arr)) | |
$render = $arrRender['pagesDir'] . '/' . $arr[0] . '/' . $arr[1]; | |
$this->render($render); # aqui gera o erro |
This file contains 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
// BusinessController.php | |
public function panel_profile() { | |
// | |
$this->layout = $this->folderLayout . "/" . Router::getParams()['prefix']; | |
$this->__afterRender(array("Business", "panel_profile")); | |
} |
This file contains 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
Fatal Error | |
Error: Call to a member function body() on a non-object | |
File: /srv/cores/CakePHP/cakephp-2.4.7/lib/Cake/Controller/Controller.php | |
Line: 954 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment