You are here

function CourseObjectBook::getNodeTypes in Course 8.2

Same name and namespace in other branches
  1. 8.3 modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php \Drupal\course_book\Plugin\course\CourseObject\CourseObjectBook::getNodeTypes()
  2. 3.x modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php \Drupal\course_book\Plugin\course\CourseObject\CourseObjectBook::getNodeTypes()

Return a list of valid node types.

Return value

array An array with node type machine names.

Overrides CourseObjectNode::getNodeTypes

File

modules/course_book/src/Plugin/course/CourseObject/CourseObjectBook.php, line 33

Class

CourseObjectBook
Plugin annotation @CourseObject( id = "book", label = "Book", handlers = { "fulfillment" = "\Drupal\course_book\Plugin\course\CourseObject\CourseObjectBookFulfillment" } )

Namespace

Drupal\course_book\Plugin\course\CourseObject

Code

function getNodeTypes() {
  if (Drupal::currentUser()
    ->hasPermission('administer book outlines')) {
    return array_keys(node_type_get_names());
  }
  else {
    $config = \Drupal::config('book.settings');
    return $config
      ->get('allowed_types');
  }
}