My plugin have a Trait “Admin” for the common actions used in backend:
<?php
namespace AdminTrait\AdminTrait;
trait AdminTrait
{
public function index() {
$this->autoRender = false;
$records = $this->{$this->name}->find();
$this->set('adminOptions',$this->adminOptions);
$this->set('records', $this->paginate($records));
if(in_array('index', $this->useAdmin)) {
return $this->render('AdminTrait.Default/index');
}
}
}
Controller:
<?php
namespace App\Controller\Admin;
use App\Controller\Admin\AppController;
class FooController extends AppController
{
use \AdminTrait\AdminTrait\AdminTrait;
}
In my controller set to use the trait and all works fine if i go to:
http://mysite/admin/Foo/index
The trait method is trigged but cake raise an Missing Template Exception:
/var/www/mysite/Template/Admin/Foo/Default/index.ctp
Why return $this->render(‘AdminTrait.Default/index’); is not fine?