You are here

public function PromoteDisableForm::promoteDisableNodeTypes in Promote Disable 8

Simple function to return a FAPI select options array.

1 call to PromoteDisableForm::promoteDisableNodeTypes()
PromoteDisableForm::buildForm in src/Form/PromoteDisableForm.php
Form constructor.

File

src/Form/PromoteDisableForm.php, line 114

Class

PromoteDisableForm
Class PromoteDisableForm.

Namespace

Drupal\promote_disable\Form

Code

public function promoteDisableNodeTypes() {
  $node_types = NodeType::loadMultiple();

  // If you need to display them in a drop down.
  $options = [];
  foreach ($node_types as $node_type) {
    $options[$node_type
      ->id()] = $node_type
      ->label();
  }
  asort($options);
  return $options;
}