Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Datatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
10 changes: 10 additions & 0 deletions src/View/Helper/DatatableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down