You are here

protected function ContentSingleExportForm::findContent in Content Synchronization 8

Same name and namespace in other branches
  1. 8.2 src/Form/ContentSingleExportForm.php \Drupal\content_sync\Form\ContentSingleExportForm::findContent()
  2. 3.0.x src/Form/ContentSingleExportForm.php \Drupal\content_sync\Form\ContentSingleExportForm::findContent()

Handles switching the content type selector.

1 call to ContentSingleExportForm::findContent()
ContentSingleExportForm::buildForm in src/Form/ContentSingleExportForm.php
Form constructor.

File

src/Form/ContentSingleExportForm.php, line 147

Class

ContentSingleExportForm
Provides a form for exporting a single content file.

Namespace

Drupal\content_sync\Form

Code

protected function findContent($content_type) {
  $names = [
    '' => $this
      ->t('- Select -'),
  ];

  // For a given entity type, load all entities.
  if ($content_type) {
    $entity_storage = $this->entityBundleManager
      ->getBundleInfo($content_type);
    foreach ($entity_storage as $entityKey => $entity) {
      $entity_id = $entityKey;
      if ($label = $entity['label']) {
        $names[$entity_id] = new TranslatableMarkup('@label (@id)', [
          '@label' => $label,
          '@id' => $entity_id,
        ]);
      }
      else {
        $names[$entity_id] = $entity_id;
      }
    }
  }
  return $names;
}