You are here

PasswordPolicyListBuilder.php in Password Policy 8.3

File

src/Controller/PasswordPolicyListBuilder.php
View source
<?php

namespace Drupal\password_policy\Controller;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * Provides a listing of Password Policies.
 */
class PasswordPolicyListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = $this
      ->t('Password Policy');
    $header['id'] = $this
      ->t('Machine name');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity
      ->label();
    $row['id'] = $entity
      ->id();

    // You probably want a few more properties here...
    return $row + parent::buildRow($entity);
  }

  /**
   * Changes the edit url to use the wizard form.
   *
   * @return array
   *   Operations for the Password Policy entity.
   */
  public function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);
    $operations['edit']['url'] = new Url('entity.password_policy.wizard.edit', [
      'machine_name' => $entity
        ->id(),
      'step' => 'general',
    ]);
    return $operations;
  }

}

Classes

Namesort descending Description
PasswordPolicyListBuilder Provides a listing of Password Policies.