You are here

protected function FeaturesExportForm::buildListing in Features 8.4

Same name and namespace in other branches
  1. 8.3 modules/features_ui/src/Form/FeaturesExportForm.php \Drupal\features_ui\Form\FeaturesExportForm::buildListing()

Builds the portion of the form showing a listing of features.

Parameters

\Drupal\features\Package[] $packages: The packages.

\Drupal\features\FeaturesBundleInterface $bundle: The current bundle.

Return value

array A render array of a form element.

1 call to FeaturesExportForm::buildListing()
FeaturesExportForm::buildForm in modules/features_ui/src/Form/FeaturesExportForm.php
Form constructor.

File

modules/features_ui/src/Form/FeaturesExportForm.php, line 240

Class

FeaturesExportForm
Defines the configuration export form.

Namespace

Drupal\features_ui\Form

Code

protected function buildListing(array $packages, FeaturesBundleInterface $bundle) {
  $header = [
    'name' => [
      'data' => $this
        ->t('Feature'),
    ],
    'machine_name' => [
      'data' => $this
        ->t(''),
    ],
    'details' => [
      'data' => $this
        ->t('Description'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'version' => [
      'data' => $this
        ->t('Version'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'status' => [
      'data' => $this
        ->t('Status'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'state' => [
      'data' => $this
        ->t('State'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
  ];
  $options = [];
  $first = TRUE;
  foreach ($packages as $package) {
    if ($first && $package
      ->getStatus() == FeaturesManagerInterface::STATUS_NO_EXPORT) {

      // Don't offer new non-profile packages that are empty.
      if ($package
        ->getStatus() === FeaturesManagerInterface::STATUS_NO_EXPORT && !$bundle
        ->isProfilePackage($package
        ->getMachineName()) && empty($package
        ->getConfig())) {
        continue;
      }
      $first = FALSE;
      $options[] = [
        'name' => [
          'data' => $this
            ->t('The following packages are not exported.'),
          'class' => 'features-export-header-row',
          'colspan' => 6,
        ],
      ];
    }
    $options[$package
      ->getMachineName()] = $this
      ->buildPackageDetail($package, $bundle);
  }
  $element = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#attributes' => [
      'class' => [
        'features-listing',
      ],
    ],
    '#prefix' => '<div id="edit-features-preview-wrapper">',
    '#suffix' => '</div>',
  ];
  return $element;
}