You are here

function _drush_onlyone_configured in Allow a content type only once (Only One) 8

Same name and namespace in other branches
  1. 7 onlyone.drush.inc \_drush_onlyone_configured()

List the content types configured in 'Only One content' mode.

File

./onlyone.drush.inc, line 116
Drush commands related to the Only One module.

Code

function _drush_onlyone_configured() {

  // Getting the configured content types.
  $onlyone_content_types = \Drupal::config('onlyone.settings')
    ->get('onlyone_node_types');
  if (count($onlyone_content_types)) {

    // Searching the content type name.
    $content_types = [];
    foreach ($onlyone_content_types as $content_type) {
      $content_type_object = NodeType::load($content_type);
      $content_types[$content_type] = $content_type_object
        ->label() . ' [' . $content_type . ']';
    }
    drush_print(dt("Content types configured in 'Only One content' mode:"));
    drush_print(' ' . implode("\n ", $content_types));
  }
  else {
    drush_print(dt("There is no content type configured in 'Only One content' mode."));
  }
}