You are here

trait ElevateZoomPlusListBuilder in ElevateZoom Plus 7

Provides a listing of ElevateZoomPlus optionsets.

Hierarchy

File

modules/ui/src/Controller/ElevateZoomPlusListBuilder.php, line 8

Namespace

Drupal\elevatezoomplus_ui\Controller
View source
trait ElevateZoomPlusListBuilder {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'elevatezoomplus_list_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header = [
      'label' => t('Optionset'),
      'responsive' => t('Responsive'),
    ];
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = check_plain($entity
      ->label());
    $row['responsive']['#markup'] = $entity
      ->getSetting('responsive') ? t('Yes') : t('No');
    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);
    if (isset($operations['edit'])) {
      $operations['edit']['title'] = t('Configure');
    }
    $operations['duplicate'] = [
      'title' => t('Duplicate'),
      'weight' => 15,
      'url' => $entity
        ->toUrl('duplicate-form'),
    ];
    if ($entity
      ->id() == 'default') {
      unset($operations['delete'], $operations['edit']);
    }
    return $operations;
  }

  /**
   * Adds some descriptive text to the elevatezoomplus optionsets list.
   *
   * @return array
   *   Renderable array.
   *
   * @see admin/config/development/configuration/single/export
   */
  public function render() {
    $build['description'] = [
      '#markup' => t("<p>Manage the ElevateZoomPlus optionsets. Optionsets are Config Entities.</p><p>By default, when this module is enabled, an optionset is created from configuration. Use the Operations column to edit, clone and delete optionsets.<br /><strong>Important!</strong> Avoid overriding Default optionset as it is meant for Default -- checking and cleaning. Use Duplicate instead. Otherwise messes are yours.<br />ElevateZoomPlus doesn't need ElevateZoomPlus UI to run. It is always safe to uninstall ElevateZoomPlus UI once done with optionsets.</p>"),
    ];
    $build[] = parent::render();
    return $build;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ElevateZoomPlusListBuilder::buildHeader public function
ElevateZoomPlusListBuilder::buildRow public function
ElevateZoomPlusListBuilder::getDefaultOperations public function
ElevateZoomPlusListBuilder::getFormId public function
ElevateZoomPlusListBuilder::render public function Adds some descriptive text to the elevatezoomplus optionsets list.