public function AbjsDefaultController::abjsExperienceAdmin in A/B Test JS 8
Same name and namespace in other branches
- 2.0.x src/Controller/AbjsDefaultController.php \Drupal\abjs\Controller\AbjsDefaultController::abjsExperienceAdmin()
Lists all experiences in default table, sorted by modified date.
For each experience, link to edit form, and list created and edited info.
1 string reference to 'AbjsDefaultController::abjsExperienceAdmin'
File
- src/
Controller/ AbjsDefaultController.php, line 236
Class
- AbjsDefaultController
- Default controller for the abjs module.
Namespace
Drupal\abjs\ControllerCode
public function abjsExperienceAdmin() {
//$db = Database::getConnection();
$date_Formatter = $this->dateFormatter;
$output = [];
$header = [
$this
->t('ID'),
$this
->t('Name'),
$this
->t('Created'),
$this
->t('Created By'),
$this
->t('Changed'),
$this
->t('Changed By'),
];
$rows = [];
$experiences = $this->database
->query("SELECT * FROM {abjs_experience} ORDER BY changed DESC, created DESC")
->fetchAll();
foreach ($experiences as $experience) {
$experience_link = [
'#title' => $experience->name,
'#type' => 'link',
'#url' => Url::fromRoute('abjs.experience_edit_form', [
'eid' => $experience->eid,
]),
];
$user_created = $this->userStorage
->load($experience->created_by);
$user_changed = $this->userStorage
->load($experience->changed_by);
$rows[] = [
'e_' . $experience->eid,
$this->renderer
->render($experience_link),
$date_Formatter
->format($experience->created),
$user_created
->toLink(),
$date_Formatter
->format($experience->changed),
$user_changed
->toLink(),
];
}
$output['add'] = [
'#title' => $this
->t('Add new experience'),
'#type' => 'link',
'#url' => Url::fromRoute('abjs.experience_add_form'),
'#attributes' => [
'class' => 'button button-action button--primary button--small',
],
'#suffix' => '<br><br>',
];
$output['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
];
return $output;
}