Skip to content

Instantly share code, notes, and snippets.

@francisrod01
Created June 21, 2014 23:04
Show Gist options
  • Save francisrod01/fdbdf99a20c53d1354ad to your computer and use it in GitHub Desktop.
Save francisrod01/fdbdf99a20c53d1354ad to your computer and use it in GitHub Desktop.
CakePHP 2.4 - Carrego um controller para o administrator com new Controller()
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();
}
}
...
}
// 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
// BusinessController.php
public function panel_profile() {
//
$this->layout = $this->folderLayout . "/" . Router::getParams()['prefix'];
$this->__afterRender(array("Business", "panel_profile"));
}
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