function legal_accept_label in Legal 8
Same name and namespace in other branches
- 2.0.x legal.module \legal_accept_label()
The accept terms and conditions label.
Parameters
bool $link: Should the label contain a link.
bool $modal: Should target be shown in a modal dialog.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup Label with markup.
2 calls to legal_accept_label()
- LegalAdminTermsForm::previewForm in src/Form/ LegalAdminTermsForm.php 
- Form elements to be displayed as a preview of the T&C form.
- legal_display_fields in ./legal.module 
- Form elements for displaying T&Cs to users.
File
- ./legal.module, line 206 
- Module file for Legal.
Code
function legal_accept_label($link = FALSE, $modal = FALSE) {
  if ($link) {
    $url = \Drupal::urlGenerator()
      ->generate('legal.legal');
    if ($modal) {
      return t('<strong>Accept</strong> @terms of Use', [
        '@terms' => Link::fromTextAndUrl(t('Terms & Conditions'), Url::fromRoute('legal.legal', [], [
          'attributes' => [
            'data-dialog-type' => 'modal',
            'data-dialog-options' => Json::encode([
              'width' => 'auto',
            ]),
            'class' => [
              'use-ajax',
            ],
            'rel' => 'nofollow',
          ],
        ]))
          ->toString(),
      ]);
    }
    else {
      return t('<strong>Accept</strong> <a href=":terms"  target="_blank">Terms & Conditions</a> of Use', [
        ':terms' => $url,
      ]);
    }
  }
  else {
    return t('<strong>Accept</strong> Terms & Conditions of Use');
  }
}