You are here

protected function MailhandlerNode::getContentTypes in Mailhandler 8

Returns an array of content types.

Return value

array An array of content types.

1 call to MailhandlerNode::getContentTypes()
MailhandlerNode::buildConfigurationForm in src/Plugin/inmail/Handler/MailhandlerNode.php

File

src/Plugin/inmail/Handler/MailhandlerNode.php, line 185

Class

MailhandlerNode
Message handler that creates a node from a mail message.

Namespace

Drupal\mailhandler\Plugin\inmail\Handler

Code

protected function getContentTypes() {

  // Find content types installed in the current system.
  $system_content_types = $this->entityTypeManager
    ->getStorage('node_type')
    ->loadMultiple();

  // Display a warning message if there are no content types available.
  if (empty($system_content_types)) {
    drupal_set_message($this
      ->t('There are no content types available. <a href=":url">Create a new one</a>.', [
      ':url' => Url::fromRoute('node.type_add')
        ->toString(),
    ]), 'warning');
  }

  // Add default option to the content type list.
  $content_types['_mailhandler'] = $this
    ->t('Detect (Mailhandler)');
  foreach ($system_content_types as $content_type) {
    $content_types[$content_type
      ->id()] = $content_type
      ->label();
  }
  return $content_types;
}