PathautoPatternListBuilder.php in Pathauto 8
File
src/PathautoPatternListBuilder.php
View source
<?php
namespace Drupal\pathauto;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
class PathautoPatternListBuilder extends DraggableListBuilder {
protected $limit = FALSE;
public function getFormId() {
return 'pathauto_pattern_list';
}
public function buildHeader() {
$header['label'] = $this
->t('Label');
$header['pattern'] = $this
->t('Pattern');
$header['type'] = $this
->t('Pattern type');
$header['conditions'] = $this
->t('Conditions');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['pattern']['#markup'] = $entity
->getPattern();
$row['type']['#markup'] = $entity
->getAliasType()
->getLabel();
$row['conditions']['#theme'] = 'item_list';
foreach ($entity
->getSelectionConditions() as $condition) {
$row['conditions']['#items'][] = $condition
->summary();
}
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (!$entity
->hasLinkTemplate('duplicate-form')) {
return $operations;
}
$operations['duplicate'] = [
'title' => $this
->t('Duplicate'),
'weight' => 0,
'url' => $this
->ensureDestination($entity
->toUrl('duplicate-form')),
];
return $operations;
}
}