base-actions-column.php
4 years ago
base-header-actions-column.php
4 years ago
base-row-actions-column.php
4 years ago
created-at-column.php
4 years ago
hidden-primary-id-column-trait.php
4 years ago
record-id-column-advanced.php
4 years ago
record-id-column.php
4 years ago
updated-at-column.php
4 years ago
base-actions-column.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Admin\Table_Views\Columns; |
| 5 | |
| 6 | use Jet_Form_Builder\Admin\Table_Views\Actions\View_Single_Action; |
| 7 | use Jet_Form_Builder\Admin\Table_Views\Column_Base; |
| 8 | |
| 9 | abstract class Base_Actions_Column extends Column_Base { |
| 10 | |
| 11 | protected $type = 'rawArray'; |
| 12 | |
| 13 | /** |
| 14 | * @return View_Single_Action[] |
| 15 | */ |
| 16 | abstract protected function get_actions(): array; |
| 17 | |
| 18 | abstract protected function is_active( View_Single_Action $action, array $record ): bool; |
| 19 | |
| 20 | public function get_value( array $record = array() ) { |
| 21 | $actions = $this->get_actions(); |
| 22 | $prepared = array(); |
| 23 | |
| 24 | foreach ( $actions as $index => $action ) { |
| 25 | if ( ! $this->is_active( $action, $record ) ) { |
| 26 | continue; |
| 27 | } |
| 28 | $prepared[] = $action->to_array( $record ); |
| 29 | } |
| 30 | |
| 31 | return $prepared; |
| 32 | } |
| 33 | |
| 34 | } |
| 35 |