public function YamlFormSubmissionListBuilder::render in YAML Form 8
Builds the entity listing as renderable array for table.html.twig.
@todo Add a link to add a new item to the #empty text.
Overrides EntityListBuilder::render
File
- src/
YamlFormSubmissionListBuilder.php, line 194
Class
- YamlFormSubmissionListBuilder
- Provides a list controller for yamlform submission entity.
Namespace
Drupal\yamlformCode
public function render() {
if ($this->yamlform) {
if ($this->account) {
$build['#title'] = $this
->t('Submissions to %yamlform for %user', [
'%yamlform' => $this->yamlform
->label(),
'%user' => $this->account
->getDisplayName(),
]);
}
}
// Add the filter.
if (empty($this->account)) {
$state_options = [
'' => $this
->t('All [@total]', [
'@total' => $this
->getTotal(NULL, NULL),
]),
'starred' => $this
->t('Starred [@total]', [
'@total' => $this
->getTotal(NULL, self::STATE_STARRED),
]),
'unstarred' => $this
->t('Unstarred [@total]', [
'@total' => $this
->getTotal(NULL, self::STATE_UNSTARRED),
]),
];
$build['filter_form'] = \Drupal::formBuilder()
->getForm('\\Drupal\\yamlform\\Form\\YamlFormSubmissionFilterForm', $this->keys, $this->state, $state_options);
}
// Customize.
if ($this->customize) {
$route_name = $this->requestHandler
->getRouteName($this->yamlform, $this->sourceEntity, 'yamlform.results_table.custom');
$route_parameters = $this->requestHandler
->getRouteParameters($this->yamlform, $this->sourceEntity) + [
'yamlform' => $this->yamlform
->id(),
];
$route_options = [
'query' => \Drupal::destination()
->getAsArray(),
];
$build['custom'] = [
'#type' => 'link',
'#title' => $this
->t('Customize'),
'#url' => Url::fromRoute($route_name, $route_parameters, $route_options),
'#attributes' => YamlFormDialogHelper::getModalDialogAttributes(800, [
'button',
'button-action',
'button--small',
'button-yamlform-setting',
]),
];
}
$build += parent::render();
$build['table']['#attributes']['class'][] = 'yamlform-results__table';
$build['#attached']['library'][] = 'yamlform/yamlform.admin';
return $build;
}