-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to set render condition callback on action (#597)
- Loading branch information
1 parent
88d4bcb
commit 50e5b81
Showing
4 changed files
with
67 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (c) 2015 ublaboo <ublaboo@paveljanda.com> | ||
* @author Pavel Janda <me@paveljanda.com> | ||
* @package Ublaboo | ||
*/ | ||
|
||
namespace Ublaboo\DataGrid\Traits; | ||
|
||
use Ublaboo\DataGrid\Row; | ||
|
||
trait TRenderCondition | ||
{ | ||
|
||
/** | ||
* @var callable|null | ||
*/ | ||
protected $render_condition_callback; | ||
|
||
|
||
/** | ||
* @param callable $condition | ||
* @return static | ||
*/ | ||
public function setRenderCondition(callable $condition) | ||
{ | ||
$this->render_condition_callback = $condition; | ||
|
||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @param Row $row | ||
* @return bool | ||
*/ | ||
public function shouldBeRendered(Row $row) | ||
{ | ||
$condition = $this->render_condition_callback; | ||
|
||
return $condition ? $condition($row->getItem()) : true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters