public function GoogleAnalyticsEventTrackerListBuilder::buildRow in Google Analytics Event Tracking 8
Same name and namespace in other branches
- 8.2 src/GoogleAnalyticsEventTrackerListBuilder.php \Drupal\google_analytics_et\GoogleAnalyticsEventTrackerListBuilder::buildRow()
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- src/
GoogleAnalyticsEventTrackerListBuilder.php, line 34
Class
- GoogleAnalyticsEventTrackerListBuilder
- Provides a listing of Google Analytics event tracker entities.
Namespace
Drupal\google_analytics_etCode
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['id'] = $entity
->id();
$paths = $entity
->get('paths');
$effective = $this
->t('All Pages');
if (!empty($paths)) {
$effective = $entity
->get('path_negate') ? $this
->t('All pages except:') : $this
->t('Only pages:');
$effective .= "\r" . $paths;
}
if ($node_types = $entity
->get('content_types')) {
$effective .= "\r" . $this
->t('Only content types:');
foreach ($node_types as $type) {
if ($node_type = NodeType::load($type)) {
$effective .= "\r" . $node_type
->label();
}
}
}
else {
$effective .= "\r" . $this
->t('All content types');
}
if ($languages = $entity
->get('languages')) {
$effective .= "\r" . $this
->t('Only languages:');
foreach ($languages as $lang) {
if ($language = \Drupal::languageManager()
->getLanguage($lang)) {
$effective .= "\r" . $language
->getName();
}
}
}
else {
$effective .= "\r" . $this
->t('All languages');
}
$row['paths']['data'] = [
'#markup' => nl2br(htmlentities($effective)),
];
$row['event'] = $entity
->get('dom_event');
$row['selector'] = $entity
->get('element_selector');
$row['category'] = $entity
->get('ga_event_category');
$row['action'] = $entity
->get('ga_event_action');
$row['ga_label'] = $entity
->get('ga_event_label');
$row['value'] = $entity
->get('ga_event_value');
$row['bounce'] = $entity
->get('ga_event_noninteraction') ? $this
->t('Yes') : $this
->t('No');
return $row + parent::buildRow($entity);
}