Provides a Tour render controller.
Expanded class hierarchy of TourRenderController
class TourRenderController extends EntityRenderController {
/**
* Overrides \Drupal\Core\Entity\EntityRenderController::viewMultiple().
*/
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
$build = array();
foreach ($entities as $entity_id => $entity) {
$tips = $entity
->getTips();
$count = count($tips);
$list_items = array();
foreach ($tips as $index => $tip) {
if ($output = $tip
->getOutput()) {
$attributes = array(
'class' => array(
'tip-module-' . drupal_clean_css_identifier($entity
->get('module')),
'tip-type-' . drupal_clean_css_identifier($tip
->get('plugin')),
'tip-' . drupal_clean_css_identifier($tip
->get('id')),
),
);
$list_items[] = array(
'output' => $output,
'counter' => array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'tour-progress',
),
),
'#children' => t('!tour_item of !total', array(
'!tour_item' => $index + 1,
'!total' => $count,
)),
),
'#wrapper_attributes' => $tip
->getAttributes() + $attributes,
);
}
}
// If there is at least one tour item, build the tour.
if ($list_items) {
end($list_items);
$key = key($list_items);
$list_items[$key]['#wrapper_attributes']['data-text'] = t('End tour');
$build[$entity_id] = array(
'#theme' => 'item_list',
'#items' => $list_items,
'#type' => 'ol',
'#attributes' => array(
'id' => 'tour',
'class' => array(
'element-hidden',
),
),
);
}
}
// If at least one tour was built, attach the tour library.
if ($build) {
$build['#attached']['library'][] = array(
'tour',
'tour',
);
}
return $build;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityRenderController:: |
protected | property | The type of entities for which this controller is instantiated. | |
EntityRenderController:: |
protected | function | Specific per-entity building. | 4 |
EntityRenderController:: |
public | function |
Implements \Drupal\Core\Entity\EntityRenderControllerInterface::buildContent(). Overrides EntityRenderControllerInterface:: |
5 |
EntityRenderController:: |
protected | function | Provides entity-specific defaults to the build process. | 3 |
EntityRenderController:: |
public | function |
Implements \Drupal\Core\Entity\EntityRenderControllerInterface::view(). Overrides EntityRenderControllerInterface:: |
1 |
EntityRenderController:: |
public | function | ||
TourRenderController:: |
public | function |
Overrides \Drupal\Core\Entity\EntityRenderController::viewMultiple(). Overrides EntityRenderController:: |