public function AbjsDefaultController::abjsConditionAdmin in A/B Test JS 8
Same name and namespace in other branches
- 2.0.x src/Controller/AbjsDefaultController.php \Drupal\abjs\Controller\AbjsDefaultController::abjsConditionAdmin()
Lists all conditions in default table, sorted by modified date.
For each condition, link to edit form, and list created and edited info.
1 string reference to 'AbjsDefaultController::abjsConditionAdmin'
File
- src/
Controller/ AbjsDefaultController.php, line 180
Class
- AbjsDefaultController
- Default controller for the abjs module.
Namespace
Drupal\abjs\ControllerCode
public function abjsConditionAdmin() {
//$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 = [];
$conditions = $this->database
->query("SELECT * FROM {abjs_condition} ORDER BY changed DESC, created DESC")
->fetchAll();
foreach ($conditions as $condition) {
$condition_link = [
'#title' => $condition->name,
'#type' => 'link',
'#url' => Url::fromRoute('abjs.condition_edit_form', [
'cid' => $condition->cid,
]),
];
$user_created = $this->userStorage
->load($condition->created_by);
$user_changed = $this->userStorage
->load($condition->changed_by);
$rows[] = [
'c_' . $condition->cid,
$this->renderer
->render($condition_link),
$date_Formatter
->format($condition->created),
$user_created
->toLink(),
$date_Formatter
->format($condition->changed),
$user_changed
->toLink(),
];
}
$output['add'] = [
'#title' => $this
->t('Add new condition'),
'#type' => 'link',
'#url' => Url::fromRoute('abjs.condition_add_form'),
'#attributes' => [
'class' => 'button button-action button--primary button--small',
],
'#suffix' => '<br><br>',
];
$output['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
];
return $output;
}