OnlyOnePrintDrush.php in Allow a content type only once (Only One) 8
File
src/OnlyOnePrintDrush.php
View source
<?php
namespace Drupal\onlyone;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class OnlyOnePrintDrush implements OnlyOnePrintStrategyInterface {
use StringTranslationTrait;
const GREEN_OUTPUT = "\33[1;32;40m\33[1m%s\33[0m";
const RED_OUTPUT = "\33[31;40m\33[1m%s\33[0m";
public function getContentTypesListForPrint(array $content_types) {
$list = [];
foreach ($content_types as $content_type => $content_type_info) {
$cant = count($content_type_info);
for ($i = 0; $i < $cant; $i++) {
$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;
}
}