Adding warning errors when an incompatible class is used.

This commit is contained in:
mark_story 2009-08-09 19:51:11 -04:00
parent 48e0e951ec
commit 4e6aa35155
2 changed files with 12 additions and 0 deletions

View file

@ -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
* adapter before including PaginatorHelper in your helpers array.
*
* The chosen custom helper must implement a `link()` method.
*
* @return void
**/
function __construct($config = array()) {
$ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js';
$this->helpers[] = $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);
}
}
/**

View file

@ -1637,6 +1637,9 @@ class PaginatorHelperTest extends CakeTestCase {
$Paginator->PaginatorMockJs =& new PaginatorMockJsHelper();
$Paginator->PaginatorMockJs->expectOnce('link');
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
$this->expectError();
$Paginator =& new PaginatorHelper(array('ajax' => 'Form'));
}
}
?>