diff --git a/src/Datatables.php b/src/Datatables.php index 5c59384..87d3c57 100644 --- a/src/Datatables.php +++ b/src/Datatables.php @@ -9,6 +9,7 @@ class Datatables public const LINK_TYPE_POST = 'POST'; public const LINK_TYPE_PUT = 'PUT'; public const LINK_TYPE_DELETE = 'DELETE'; + public const LINK_TYPE_CUSTOM = 'CUSTOM'; public static function postLinkMethods() { diff --git a/src/View/Helper/DatatableHelper.php b/src/View/Helper/DatatableHelper.php index aca54c5..fffd815 100644 --- a/src/View/Helper/DatatableHelper.php +++ b/src/View/Helper/DatatableHelper.php @@ -669,7 +669,17 @@ protected function processActionLink(array $link): string case Datatables::LINK_TYPE_POST: $output = new \CakeDC\Datatables\View\Formatter\Link\PostLink($this, $link); break; + case Datatables::LINK_TYPE_CUSTOM: + if (!is_callable($link['formatter'] ?? null)) { + throw new \OutOfBoundsException("Please specify a custom formatter"); + } + $output = new $link['formatter']($this,$link); + if (!method_exists($output, 'link')){ + throw new \OutOfBoundsException("Method link is not found in class"); + } + + break; case Datatables::LINK_TYPE_GET: default: $output = new \CakeDC\Datatables\View\Formatter\Link\Link($this, $link);