mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-01 01:26:19 +00:00
Adding warning errors when an incompatible class is used.
This commit is contained in:
parent
48e0e951ec
commit
4e6aa35155
2 changed files with 12 additions and 0 deletions
|
@ -80,12 +80,21 @@ class PaginatorHelper extends AppHelper {
|
||||||
* or choose a non JsHelper Helper. If you want to use a specific library with JsHelper declare JsHelper and its
|
* or choose a non JsHelper Helper. If you want to use a specific library with JsHelper declare JsHelper and its
|
||||||
* adapter before including PaginatorHelper in your helpers array.
|
* adapter before including PaginatorHelper in your helpers array.
|
||||||
*
|
*
|
||||||
|
* The chosen custom helper must implement a `link()` method.
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function __construct($config = array()) {
|
function __construct($config = array()) {
|
||||||
$ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js';
|
$ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js';
|
||||||
$this->helpers[] = $ajaxProvider;
|
$this->helpers[] = $ajaxProvider;
|
||||||
$this->_ajaxHelperClass = $ajaxProvider;
|
$this->_ajaxHelperClass = $ajaxProvider;
|
||||||
|
if (!method_exists($ajaxProvider . 'Helper', 'link')) {
|
||||||
|
$message = sprintf(
|
||||||
|
__('%s does not implement a link() method, it is incompatible with PaginatorHelper', true),
|
||||||
|
$ajaxProvider . 'Helper'
|
||||||
|
);
|
||||||
|
trigger_error($message, E_USER_WARNING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1637,6 +1637,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$Paginator->PaginatorMockJs =& new PaginatorMockJsHelper();
|
$Paginator->PaginatorMockJs =& new PaginatorMockJsHelper();
|
||||||
$Paginator->PaginatorMockJs->expectOnce('link');
|
$Paginator->PaginatorMockJs->expectOnce('link');
|
||||||
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
|
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
|
||||||
|
|
||||||
|
$this->expectError();
|
||||||
|
$Paginator =& new PaginatorHelper(array('ajax' => 'Form'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue