public function TwitterAccountsController::display_accounts in Tweet Feed 4.x
Same name and namespace in other branches
- 8.3 src/Controller/TwitterAccountsController.php \Drupal\tweet_feed\Controller\TwitterAccountsController::display_accounts()
display_accounts().
Return value
array Return render array of a table of elements that make up the list of available twitter accounts or an empty list. Designed to be handled by Drupal's configuration management system.
1 string reference to 'TwitterAccountsController::display_accounts'
File
- src/
Controller/ TwitterAccountsController.php, line 22
Class
- TwitterAccountsController
- Class TwitterAccountsController.
Namespace
Drupal\tweet_feed\ControllerCode
public function display_accounts() {
$config = $this
->config('tweet_feed.twitter_accounts');
$header = [
[
'data' => $this
->t('Account Name'),
],
[
'data' => $this
->t('Account Machine Name'),
],
[
'data' => $this
->t('Edit'),
],
[
'data' => $this
->t('Delete'),
],
];
$rows = [];
$accounts = $config
->get('accounts');
foreach ($accounts as $account_machine_name => $account) {
$edit_link = Link::createFromRoute($this
->t('Edit'), 'tweet_feed.edit_account', [
'account_machine_name' => $account_machine_name,
]);
$delete_link = Link::createFromRoute($this
->t('Delete'), 'tweet_feed.delete_account', [
'account_machine_name' => $account_machine_name,
]);
$row = [
[
'data' => $account['account_name'],
],
[
'data' => $account_machine_name,
],
[
'data' => $edit_link,
],
[
'data' => $delete_link,
],
];
$rows[] = $row;
}
return [
'#type' => 'table',
'#attributes' => [
'class' => [
'table table-striped',
],
],
'#prefix' => NULL,
'#header' => $header,
'#rows' => $rows,
'#empty' => 'THERE ARE NO TWITTER API ACCOUNTS CURRENTLY CREATED.',
];
}