/** * Render a filtered list of entries in the database. */ public function entryAdvancedList() { $content = array(); $content['message'] = array('#markup' => $this->t('A more complex list of entries in the database.') . ' ' . $this->t('Only the entries with name = "John" and age older than 18 years are shown, the username of the person who created the entry is also shown.')); $headers = array(t('Id'), t('Created by'), t('Name'), t('Surname'), t('Age')); $rows = array(); foreach ($entries = DBTNGExampleStorage::advancedLoad() as $entry) { // Sanitize each entry. $rows[] = array_map('Drupal\\Component\\Utility\\SafeMarkup::checkPlain', $entry); } $content['table'] = array('#type' => 'table', '#header' => $headers, '#rows' => $rows, '#attributes' => array('id' => 'dbtng-example-advanced-list'), '#empty' => t('No entries available.')); return $content; }