You are here

class AdminHelper in moderated content bulk publish 8

Same name and namespace in other branches
  1. 2.0.x src/AdminHelper.php \Drupal\moderated_content_bulk_publish\AdminHelper
  2. 1.0.x src/AdminHelper.php \Drupal\moderated_content_bulk_publish\AdminHelper

Hierarchy

  • class \Drupal\moderated_content_bulk_publish\AdminHelper

Expanded class hierarchy of AdminHelper

2 files declare their use of AdminHelper
AdminModeration.php in src/AdminModeration.php
AdminPin.php in src/AdminPin.php

File

src/AdminHelper.php, line 5

Namespace

Drupal\moderated_content_bulk_publish
View source
class AdminHelper {
  public static function addMessage($message) {
    \Drupal::messenger()
      ->addMessage($message);
  }
  public static function addToLog($message, $DEBUG = FALSE) {

    //$DEBUG = TRUE;
    if ($DEBUG) {
      \Drupal::logger('moderated_content_bulk_publish')
        ->notice($message);
    }
  }

  /**
   * Helper function to get all enabled languages, excluding current language.
   */
  public static function getOtherEnabledLanguages() {

    // Get the list of all languages
    $language = \Drupal::languageManager()
      ->getCurrentLanguage();
    $languages = \Drupal::languageManager()
      ->getLanguages();
    $other_languages = array();

    // Add each enabled language, aside from the current language to an array.
    foreach ($languages as $field_language_code => $field_language) {
      if ($field_language_code != $language
        ->getId()) {
        $other_languages[$field_language_code] = $field_language
          ->getName();
      }
    }
    return $other_languages;
  }

  /**
   * Helper function get current language.
   */
  public static function getDefaultLangcode() {
    $language = \Drupal::languageManager()
      ->getDefaultLanguage();
    return $language
      ->getId();
  }

  /**
   * Helper function to get all enabled languages, including the current language.
   */
  public static function getAllEnabledLanguages() {

    // Get the list of all languages
    $language = \Drupal::languageManager()
      ->getCurrentLanguage();
    $languages = \Drupal::languageManager()
      ->getLanguages();
    $other_languages = array();

    // Add each enabled language, aside from the current language to an array.
    foreach ($languages as $field_language_code => $field_language) {
      $other_languages[$field_language_code] = $field_language
        ->getName();
    }
    return $other_languages;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminHelper::addMessage public static function
AdminHelper::addToLog public static function
AdminHelper::getAllEnabledLanguages public static function Helper function to get all enabled languages, including the current language.
AdminHelper::getDefaultLangcode public static function Helper function get current language.
AdminHelper::getOtherEnabledLanguages public static function Helper function to get all enabled languages, excluding current language.