Refactor generic tables and page index classes #26

Merged
Roflin merged 9 commits from refactor-tables into master 2021-05-17 20:19:18 +02:00
Showing only changes of commit 5c55e45c3c - Show all commits

View File

@ -37,7 +37,7 @@ class GenericTable extends PageIndex
$this->tableIsSortable = !empty($options['base_url']); $this->tableIsSortable = !empty($options['base_url']);
// How much stuff do we have? // How much stuff do we have?
$this->recordCount = call_user_func_array($options['get_count'], !empty($options['get_count_params']) ? $options['get_count_params'] : []); $this->recordCount = $options['get_count'](...(!empty($options['get_count_params']) ? $options['get_count_params'] : []));
// Should we create a page index? // Should we create a page index?
$this->items_per_page = !empty($options['items_per_page']) ? $options['items_per_page'] : 30; $this->items_per_page = !empty($options['items_per_page']) ? $options['items_per_page'] : 30;
@ -60,7 +60,7 @@ class GenericTable extends PageIndex
$parameters = array_merge($parameters, $options['get_data_params']); $parameters = array_merge($parameters, $options['get_data_params']);
// Okay, let's fetch the data! // Okay, let's fetch the data!
$data = call_user_func_array($options['get_data'], $parameters); $data = $options['get_data'](...$parameters);
// Clean up a bit. // Clean up a bit.
$rows = $data['rows']; $rows = $data['rows'];
@ -150,7 +150,7 @@ class GenericTable extends PageIndex
$parameters = [$column['parse']['data']['pattern']]; $parameters = [$column['parse']['data']['pattern']];
foreach ($column['parse']['data']['arguments'] as $identifier) foreach ($column['parse']['data']['arguments'] as $identifier)
$parameters[] = $row[$identifier]; $parameters[] = $row[$identifier];
$value = call_user_func_array('sprintf', $parameters); $value = sprintf(...$parameters);
break; break;
// timestamps: let's make them readable! // timestamps: let's make them readable!