控制器不工作

Controller no work

路线:

$routes->connect('/textos',['controller' => 'Administracion', 'action' => 'textos']);

控制器:

class AdministracionController extends AppController {
  public function textos() {
    $this->set('textos', $this->Textos->find('all'));
  }
}

模型 ---> TextosTable

Error: Call to a member function find() on boolean File /srv/www/cake-arbol/src/Controller/AdministracionController.php Line: 20

第 20 行:$this->set('textos', $this->Textos->find('all'));

什么问题?名字 table 是 Textos

问题出在行 $this->Textos->find('all')

使用前必须加载模型Textos,

use Cake\ORM\TableRegistry;

class AdministracionController extends AppController {
  public function textos() {
    $textos = TableRegistry::get('Textos');
    $this->set('textos', $textos->find('all'));
  }
}