Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions en/appendices/3-5-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ Console
allows you to set the command name used when generating help output. Defaults
to ``cake``.

Datasource
----------

* ``Cake\Datasource\SchemaInterface`` was added.
* New abstract types were added for ``smallinteger`` and ``tinyinteger``.
Existing ``SMALLINT`` and ``TINYINT`` columns will now be reflected as these
new abstract types. ``TINYINT(1)`` columns will continue to be treated as
boolean columns in MySQL.
* ``Cake\Datasource\PaginatorInterface`` was added. The ``PaginatorComponent``
now uses this interface to interact with paginators. This allows other
ORM-like implementations to be paginated by the component.
* ``Cake\Datasource\Paginator`` was added to paginate ORM/Database Query
instances.

Event
-----

* ``Cake\Event\EventManager::on()`` and ``off()`` methods are now chainable
making it simpler to set multiple events at once.

Http
----

Expand All @@ -153,20 +173,9 @@ Http
* ``Cake\Http\Client::addCookie()`` was added to make it easy to add cookies to
a client instance.

Event
-----

* ``Cake\Event\EventManager::on()`` and ``off()`` methods are now chainable
making it simpler to set multiple events at once.

ORM
---

* ``Cake\Datasource\SchemaInterface`` was added.
* New abstract types were added for ``smallinteger`` and ``tinyinteger``.
Existing ``SMALLINT`` and ``TINYINT`` columns will now be reflected as these
new abstract types. ``TINYINT(1)`` columns will continue to be treated as
boolean columns in MySQL.
* ``Cake\ORM\Query::contain()`` now allows you to call it without the wrapping
array when containing a single association. ``contain('Comments', function ()
{ ... });`` will now work. This makes ``contain()`` consistent with other
Expand Down
44 changes: 44 additions & 0 deletions en/views/cells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,47 @@ name will be used.
do not share context with the main template / layout. Each cell is
self-contained and only has access to variables passed as arguments to the
``View::cell()`` call.


Paginating Data inside a Cell
=============================

Creating a cell that renders a paginated result set can be done by leveraging
the ``Paginator`` class of the ORM. An example of paginating a user's favorite
messages could look like::

namespace App\View\Cell;

use Cake\View\Cell;
use Cake\Datasource\Paginator;

class FavoritesCell extends Cell
{
public function display($user)
{
$this->loadModel('Messages');

// Create a paginator
$paginator = new Paginator();

// Paginate the model
$results = $paginator->paginate(
$this->Messages,
$this->request->getQueryParams(),
[
// Use a parameterized custom finder.
'finder' => ['favorites' => [$user]],

// Use scoped query string parameters.
'scope' => 'favorites',
]
);
$this->set('favorites', $results);
}
}

The above cell would paginate the ``Messages`` model using :ref:`scoped
pagination parameters <paginating-multiple-queries>`.

.. versionadded:: 3.5.0
``Cake\Datasource\Paginator`` was added in 3.5.0.