You are here

class OnlyOnePrintAdminPage in Allow a content type only once (Only One) 8

Class OnlyOnePrintAdminPage.

Hierarchy

Expanded class hierarchy of OnlyOnePrintAdminPage

2 files declare their use of OnlyOnePrintAdminPage
OnlyOnePrintAdminPageTest.php in tests/src/Unit/OnlyOnePrintAdminPageTest.php
OnlyOneTest.php in tests/src/Unit/OnlyOneTest.php

File

src/OnlyOnePrintAdminPage.php, line 8

Namespace

Drupal\onlyone
View source
class OnlyOnePrintAdminPage implements OnlyOnePrintStrategyInterface {

  /**
   * {@inheritdoc}
   */
  public function getContentTypesListForPrint(array $content_types) {
    $list = [];

    // Iterating over each content type.
    foreach ($content_types as $content_type => $content_type_info) {
      $cant = count($content_type_info);

      // Iterating over each language.
      for ($i = 0; $i < $cant; $i++) {

        // Example for multilingual sites:
        // Article (En: 7 Nodes, Fr: 5 Nodes, Not specified: 2 Nodes).
        // Example for non multilingual sites:
        // Article (3 Nodes).
        $list[$content_type] = $content_type_info[$i]->name . ' <strong>(' . implode(', ', array_column($content_type_info, 'total_nodes')) . ')</strong>';
      }
    }
    return $list;
  }

}

Members