"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/node/src/NodeTypeListBuilder.php" (26 Nov 2020, 1584 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "NodeTypeListBuilder.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\node;
    4 
    5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
    6 use Drupal\Core\Url;
    7 use Drupal\Core\Entity\EntityInterface;
    8 
    9 /**
   10  * Defines a class to build a listing of node type entities.
   11  *
   12  * @see \Drupal\node\Entity\NodeType
   13  */
   14 class NodeTypeListBuilder extends ConfigEntityListBuilder {
   15 
   16   /**
   17    * {@inheritdoc}
   18    */
   19   public function buildHeader() {
   20     $header['title'] = t('Name');
   21     $header['description'] = [
   22       'data' => t('Description'),
   23       'class' => [RESPONSIVE_PRIORITY_MEDIUM],
   24     ];
   25     return $header + parent::buildHeader();
   26   }
   27 
   28   /**
   29    * {@inheritdoc}
   30    */
   31   public function buildRow(EntityInterface $entity) {
   32     $row['title'] = [
   33       'data' => $entity->label(),
   34       'class' => ['menu-label'],
   35     ];
   36     $row['description']['data'] = ['#markup' => $entity->getDescription()];
   37     return $row + parent::buildRow($entity);
   38   }
   39 
   40   /**
   41    * {@inheritdoc}
   42    */
   43   public function getDefaultOperations(EntityInterface $entity) {
   44     $operations = parent::getDefaultOperations($entity);
   45     // Place the edit operation after the operations added by field_ui.module
   46     // which have the weights 15, 20, 25.
   47     if (isset($operations['edit'])) {
   48       $operations['edit']['weight'] = 30;
   49     }
   50     return $operations;
   51   }
   52 
   53   /**
   54    * {@inheritdoc}
   55    */
   56   public function render() {
   57     $build = parent::render();
   58     $build['table']['#empty'] = $this->t('No content types available. <a href=":link">Add content type</a>.', [
   59         ':link' => Url::fromRoute('node.type_add')->toString(),
   60       ]);
   61     return $build;
   62   }
   63 
   64 }