function CdbController::adminListPage in Dynamic Banner 8
Return a listing of all defined URL aliases.
1 string reference to 'CdbController::adminListPage'
File
- src/
application/ Controller/ CdbController.php, line 15
Class
Namespace
Drupal\dynamic_banner\application\ControllerCode
function adminListPage() {
$output = [];
// default
// construct the headers of the table
$header = array(
array(
'data' => t('Url'),
'field' => 'd.path',
'sort' => 'asc',
),
array(
'data' => t('ImgUrl'),
),
array(
'data' => t('Text'),
'field' => 'd.text',
),
array(
'data' => t('Link'),
'field' => 'd.link',
),
array(
'data' => t('Mode'),
'field' => 'd.mode',
),
array(
'data' => t('Operations'),
'colspan' => '2',
),
);
$query = \Drupal::database()
->select('dynamic_banner', 'd')
->extend('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender')
->extend('\\Drupal\\Core\\Database\\Query\\TableSortExtender');
$query = $query
->fields('d', array(
'dbid',
'path',
'imgurl',
'imgfid',
'text',
'link',
'mode',
));
$query = $query
->limit(10)
->orderByHeader($header);
$result = $query
->execute();
// start constructing the individual rows
$rows = array();
foreach ($result as $data) {
$editUrl = Url::fromRoute('cdb.banneredit', array(
'bid' => $data->dbid,
));
$editLink = Link::fromTextAndUrl(t('Edit'), $editUrl);
$delUrl = Url::fromRoute('cdb.bannerdel', array(
'bid' => $data->dbid,
));
$delLink = Link::fromTextAndUrl(t('Delete'), $delUrl);
$image = $this
->dynamic_banner_image_handler($data->imgurl, $data->imgfid);
$rows[] = array(
'data' => array(
$data->path,
$image,
$data->text,
$data->link,
$data->mode,
$editLink,
$delLink,
),
);
}
// construct the call for the theme function to run on this
$output['dynamic_banner_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No Banners Found.'),
);
// adds the pager buttons to the bottom of the table
$output['dynamic_banner_pager'] = array(
'#type' => 'pager',
);
// let drupal handle print and echo
return $output;
}