class OnlyOnePrintAdminPage in Allow a content type only once (Only One) 8
Class OnlyOnePrintAdminPage.
Hierarchy
- class \Drupal\onlyone\OnlyOnePrintAdminPage implements OnlyOnePrintStrategyInterface
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\onlyoneView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OnlyOnePrintAdminPage:: |
public | function |
Return a list of content types for print. Overrides OnlyOnePrintStrategyInterface:: |