public function BusinessRulesUtil::getViewsOptions in Business Rules 8
Same name and namespace in other branches
- 2.x src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getViewsOptions()
Get a list of views to display in a option box.
Parameters
string $views_display: The views display plugin if you want to filter by display.
Return value
array Options array.
File
- src/
Util/ BusinessRulesUtil.php, line 722
Class
- BusinessRulesUtil
- Class BusinessRulesUtil.
Namespace
Drupal\business_rules\UtilCode
public function getViewsOptions($views_display = NULL) {
$views = Views::getAllViews();
$options = [];
foreach ($views as $view) {
$id = $view
->id();
$big_description = strlen($view
->get('description') > 100) ? '...' : '';
foreach ($view
->get('display') as $display) {
if (empty($views_display) || $display['display_plugin'] == $views_display) {
$options[$view
->label() . ' : ' . substr($view
->get('description'), 0, 100) . $big_description][$id . ':' . $display['id']] = $this
->t('@view : @display_id : @display_title', [
'@view' => $view
->label(),
'@display_id' => $display['id'],
'@display_title' => $display['display_title'],
]);
}
}
}
ksort($options);
return $options;
}