PatternListBuilder.php in View Mode Page 4.0.x
File
src/Form/PatternListBuilder.php
View source
<?php
namespace Drupal\view_mode_page\Form;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
class PatternListBuilder extends DraggableListBuilder {
public function getFormId() {
return 'view_mode_page_pattern_list';
}
public function buildHeader() {
$header['label'] = $this
->t('Label');
$header['pattern'] = $this
->t('Pattern');
$header['type'] = $this
->t('Entity type');
$header['view_mode'] = $this
->t('View mode');
$header['conditions'] = $this
->t('Conditions');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['patern']['#markup'] = $entity
->getPattern();
$row['type']['#markup'] = $entity
->getAliasType()
->getLabel();
$row['view_mode']['#markup'] = $entity
->getViewModeLabel();
$row['conditions']['#theme'] = 'item_list';
foreach ($entity
->getSelectionConditions() as $condition) {
$row['conditions']['#items'][] = $condition
->summary();
}
return $row + parent::buildRow($entity);
}
}