Cakephp 重定向给出错误 Call to a member function header() on null

Cakephp redirect is giving the error Call to a member function header() on null

//奖项控制器

App::import('Controller', 'Permissions');
        class AwardsController extends AppController {
        public function add($id=NULL) {
            if (!$id) {
                throw new NotFoundException(__('Invalid User'));
            }
            if(!$this->Session->check('Auth.User')){
                $this->redirect(array('controller'=>'users','action' => 'login'));      
            }else{
                $Permission= new PermissionsController;
                if($Permission->isAuth($id)){
                    if ($this->request->is('post')) {
                        $this->Award->create();
                        $this->request->data['Award'][0]['basicprofile_id']=10;
                        var_dump($this->data);
                        if ($this->Award->saveAll($this->request->data['Award'])) {
                            $this->Session->setFlash(__('Award has been added '));
                            //$Permission= new PermissionsController;
                            //$this->redirect(array('controller'=>'users','action' => 'login'));
                            $Permission->redirectProfile($id);
                        } else {
                            $this->set('error',sizeof($this->request->data['Award']));
                            $this->Session->setFlash(__('The award has not added. Please, try again.'));
                        }   
                    }
                }else{
                    $this->Session->setFlash(__('You are not authorized to access it'));
                    $this->redirect(array('controller'=>'users','action' => 'login'));
                }
            }
        }
    }

//premissioncontroller

 <?php

        class PermissionsController extends AppController {


        public function redirectProfile($id){
            if(AuthComponent::user('role')=='Admin'){echo "working";
                $this->redirect(array('controller'=>'users','action' => 'index'));
            }else if(AuthComponent::user('role')=='Teacher'){
                //$this->redirect(array('controller'=>'profiles','action' => 'teacher', $id));
            }
        }
    }

    ?>

在 permissioncontroller 中回显正在打印,但 url 的重新定向给出了致命错误:在 null 上调用成员函数 header() 。任何建议

我想出了窍门。 //奖项控制器

App::import('Controller', 'Permissions');
        class AwardsController extends AppController {
        public function add($id=NULL) {
            if (!$id) {
                throw new NotFoundException(__('Invalid User'));
            }
            if(!$this->Session->check('Auth.User')){
                $this->redirect(array('controller'=>'users','action' => 'login'));      
            }else{
                $Permission= new PermissionsController;
                if($Permission->isAuth($id)){
                    if ($this->request->is('post')) {
                        $this->Award->create();
                        $this->request->data['Award'][0]['basicprofile_id']=10;
                        var_dump($this->data);
                        if ($this->Award->saveAll($this->request->data['Award'])) {
                            $this->Session->setFlash(__('Award has been added '));
                            //$Permission= new PermissionsController;
                            //$this->redirect(array('controller'=>'users','action' => 'login'));
                            $this->redirect($Permission->redirectProfile($id));
                        } else {
                            $this->set('error',sizeof($this->request->data['Award']));
                            $this->Session->setFlash(__('The award has not added. Please, try again.'));
                        }   
                    }
                }else{
                    $this->Session->setFlash(__('You are not authorized to access it'));
                    $this->redirect(array('controller'=>'users','action' => 'login'));
                }
            }
        }
    }

//权限控制器

<?php

  class PermissionsController extends AppController {
public function redirectProfile($id){
            if(AuthComponent::user('role')=='Admin'){echo "working";
                return (array('controller'=>'users','action' => 'index'));
            }else if(AuthComponent::user('role')=='Teacher'){
                return (array('controller'=>'profiles','action' => 'teacher', $id));
            }
        }
    }

    ?>

只需 return url 地址即可重定向并从 awardscontroller 本身重定向。