Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit b712c74

Browse files
author
David Yell
committed
The table methods should use the new setters. The controller method should pass the paginate options instead of using the query
1 parent 69fcaf5 commit b712c74

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/Template/Bake/Element/Controller/index.ctp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
$query->contain([<%= $this->Bake->stringifyList($belongsTo, ['indent' => false]) %>]);
1212
<% endif; %>
1313

14-
if (empty($this->request->getQuery('sort'))) {
15-
$query->order([$this-><%= $currentModelName %>->aliasField('modified') => 'desc']);
16-
}
17-
18-
$this->set('<%= $pluralName %>', $this->paginate($query));
14+
$this->set('<%= $pluralName %>', $this->paginate($query, [
15+
'order' => [$this-><%= $currentModelName %>->aliasField('modified') => 'desc']
16+
));
1917
}

src/Template/Bake/Model/table.ctp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ class <%= $name %>Table extends Table
4141
public function initialize(array $config)
4242
{
4343
<% if (!empty($table)): %>
44-
$this->table('<%= $table %>');
44+
$this->setTable('<%= $table %>');
4545
<% endif %>
4646
<% if (!empty($displayField)): %>
47-
$this->displayField('<%= $displayField %>');
47+
$this->setDisplayField('<%= $displayField %>');
4848
<% endif %>
4949
<% if (!empty($primaryKey)): %>
5050
<% if (count($primaryKey) > 1): %>
51-
$this->primaryKey([<%= $this->Bake->stringifyList((array)$primaryKey, ['indent' => false]) %>]);
51+
$this->setPrimaryKey([<%= $this->Bake->stringifyList((array)$primaryKey, ['indent' => false]) %>]);
5252
<% else: %>
53-
$this->primaryKey('<%= current((array)$primaryKey) %>');
53+
$this->setPrimaryKey('<%= current((array)$primaryKey) %>');
5454
<% endif %>
5555
<% endif %>
5656

0 commit comments

Comments
 (0)