Skip to content

Commit

Permalink
Adding warning errors when an incompatible class is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 9, 2009
1 parent 48e0e95 commit 4e6aa35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -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);
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -1637,6 +1637,9 @@ function testMockAjaxProviderClassInjection() {
$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'));
}
}
?>

0 comments on commit 4e6aa35

Please sign in to comment.