public function paginate($object = null, array $settings = [])
{
if (is_object($object)) {
$table = $object;
}
if (is_string($object) || $object === null) {
$try = [$object, $this->modelClass];
foreach ($try as $tableName) {
if (empty($tableName)) {
continue;
}
$table = $this->loadModel($tableName);
break;
}
}
$this->loadComponent('Paginator');
if (empty($table)) {
throw new RuntimeException('Unable to locate an object compatible with paginate.');
}
$settings = $settings + $this->paginate;
return $this->Paginator->paginate($table, $settings);
}