Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding warning errors when an incompatible class is used.

  • Loading branch information...
commit a7e300a7c1c90bc64c7e85ce62732458c22befa7 1 parent 2988156
@markstory markstory authored
View
9 cake/libs/view/helpers/paginator.php
@@ -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
3  cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -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'));
}
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.