You are here

public function AgreeTerms::buildConfigurationSummary in Commerce Agree Terms 8

Builds a summary of the pane configuration.

Complements the methods provided by PluginFormInterface, allowing the checkout flow form to provide a summary of pane configuration.

Return value

string An HTML summary of the pane configuration.

Overrides CheckoutPaneBase::buildConfigurationSummary

File

src/Plugin/Commerce/CheckoutPane/AgreeTerms.php, line 38

Class

AgreeTerms
Provides the completion message pane.

Namespace

Drupal\commerce_agree_terms\Plugin\Commerce\CheckoutPane

Code

public function buildConfigurationSummary() {
  $prefix = $this->configuration['prefix_text'];
  $link_text = $this->configuration['link_text'];
  $invalid_text = $this->configuration['invalid_text'];
  $new_window = $this->configuration['new_window'];
  $nid = $this->configuration['nid'];
  $summary = '';
  if (!empty($prefix)) {
    $summary = $this
      ->t('Prefix text: @text', [
      '@text' => $prefix,
    ]) . '<br/>';
  }
  if (!empty($link_text)) {
    $summary .= $this
      ->t('Link text: @text', [
      '@text' => $link_text,
    ]) . '<br/>';
  }
  if (!empty($invalid_text)) {
    $summary .= $this
      ->t('Error text: @text', [
      '@text' => $invalid_text,
    ]) . '<br/>';
  }
  if (!empty($window_target)) {
    $window_text = $new_window === 1 ? $this
      ->t('New window') : $this
      ->t('Same window');
    $summary .= $this
      ->t('Window opens in: @opens', [
      '@text' => $window_text,
    ]) . '<br/>';
  }
  if (!empty($nid)) {
    $node = Node::load($nid);
    if ($node) {
      $summary .= $this
        ->t('Terms page: @title', [
        '@title' => $node
          ->getTitle(),
      ]);
    }
  }
  return $summary;
}