Cake Bake generated code (scaffolding) resulting in syntax error

61 Views Asked by At

Cake Bake generated the following code snipped:

public function index()
{
$this->paginate = [
        'contain' => ['Users']
    ];

    $shops = $this->paginate($this->Shops);

    $this->set(compact('shops'));
}

The result is the error message: syntax error, unexpected 'use' (T_USE)

When I change the code to this it works:

public function index()
{
    $this->paginate = [
        'contain' => ['Users']
    ];

    // $shops = $this->paginate($this->Shops);
    $this->loadComponent('Paginator');
    $shops = $this->Paginator->paginate($this->Shops->find());

    $this->set(compact('shops'));
}

I find this strange in particular because the first code version is generated by cake bake and supposed to work straight away, isnt it?

0

There are 0 best solutions below