class OnlyOnePrintDrush in Allow a content type only once (Only One) 8
Class OnlyOnePrintDrush.
Hierarchy
- class \Drupal\onlyone\OnlyOnePrintDrush implements OnlyOnePrintStrategyInterface uses StringTranslationTrait
Expanded class hierarchy of OnlyOnePrintDrush
3 files declare their use of OnlyOnePrintDrush
- onlyone.drush.inc in ./
onlyone.drush.inc - Drush commands related to the Only One module.
- OnlyOnePrintDrushTest.php in tests/
src/ Unit/ OnlyOnePrintDrushTest.php - OnlyOneTest.php in tests/
src/ Unit/ OnlyOneTest.php
File
- src/
OnlyOnePrintDrush.php, line 10
Namespace
Drupal\onlyoneView source
class OnlyOnePrintDrush implements OnlyOnePrintStrategyInterface {
use StringTranslationTrait;
/**
* Green color for text used in drush commands.
*/
const GREEN_OUTPUT = "\33[1;32;40m\33[1m%s\33[0m";
/**
* Red color for text used in drush commands.
*/
const RED_OUTPUT = "\33[31;40m\33[1m%s\33[0m";
/**
* {@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 . ' (' . implode(', ', array_column($content_type_info, 'total_nodes')) . ')';
$list[$content_type] .= $content_type_info[$i]->configured ? ' ' . sprintf(self::GREEN_OUTPUT, $this
->t('Configured')) : '';
}
}
return $list;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OnlyOnePrintDrush:: |
public | function |
Return a list of content types for print. Overrides OnlyOnePrintStrategyInterface:: |
|
OnlyOnePrintDrush:: |
constant | Green color for text used in drush commands. | ||
OnlyOnePrintDrush:: |
constant | Red color for text used in drush commands. | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |