public function UserSection::getItems in Workbench Access 8
Items should be stored in the result array, if possible, as an array with 'value' as the actual displayable value of the item, plus any items that might be found in the 'alter' options array for creating links, such as 'path', 'fragment', 'query' etc, such a thing is to be made. Additionally, items that might be turned into tokens should also be in this array.
Overrides Section::getItems
File
- src/
Plugin/ views/ field/ UserSection.php, line 97
Class
- UserSection
- Field handler to present the section assigned to the user.
Namespace
Drupal\workbench_access\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
$this->items = [];
$user = $this
->getEntity($values);
$all = $this->scheme
->getAccessScheme()
->getTree();
if ($this->manager
->userInAll($this->scheme, $user)) {
$sections = $this->manager
->getAllSections($this->scheme, TRUE);
}
else {
$sections = $this->userSectionStorage
->getUserSections($this->scheme, $user);
}
foreach ($sections as $id) {
foreach ($all as $root => $data) {
if (isset($data[$id])) {
// Check for link.
if ($this->options['make_link'] && isset($data[$id]['path'])) {
$this->items[$id]['path'] = $data[$id]['path'];
$this->items[$id]['make_link'] = TRUE;
}
$this->items[$id]['value'] = $this
->sanitizeValue($data[$id]['label']);
}
}
}
return $this->items;
}