Вызов функции-члена при ошибке null CodeIgniter

Пожалуйста, не спрашивайте, почему у меня есть более одного контроллера: это то, чего хочет мой учитель. У меня есть 3 контроллера: Api.php , Token.php и Apikey.php , где Api.php является «основным».

ПРОБЛЕМА : Когда я перехожу в URL-адрес : http: //localhost/revolution/index.php/api/registerUser/first_name/12First

кажется, что есть проблемы с загрузкой контроллера Token из контроллера Api .

ОШИБКА: Неустранимая ошибка: вызов функции-члена generateToken () на null

Что я могу сделать?

API-контроллер: Api.php

class api extends CI_Controller { public function index() { parent::__construct(); $this->load->library("../controllers/Apikey.php"); $this->load->library("../controllers/Token.php"); } public function registerUser ($username,$parola) { if ($this->isValidUserName($username) && $this->isValidPass($parola)) { $this->load->library("../controllers/Token"); $id = $this->ApiModel->insertCredentials($username, md5($parola)); $this->Token->generateToken($id); $this->ApiKey->generateApiKey($id); $data['registered'] = 1; $this->load->view('api', $data); } } } 

Контроллер Token.php

  public function existsToken($token) { $arrayTokens = $this->ApiModel->getAllTokens(); if (in_array($token, $arrayTokens)) return existsToken(sha1($this->randomString())); //$this->isValidToken(sha1($this->randomString())); return $token; } public function randomString() { return intval(993432422 % rand()); } public function generateToken($id_user) { $token = $this->existsToken(sha1($this->randomString())); $date = $this->generateExpDate(); $result = $this->ApiModel->insertToken($token, $date, $id_user); } 

Related of "Вызов функции-члена при ошибке null CodeIgniter"