You are here

function quote_form_alter in Quote 8.2

Same name and namespace in other branches
  1. 5 quote.module \quote_form_alter()
  2. 6.2 quote.module \quote_form_alter()
  3. 6 quote.module \quote_form_alter()
  4. 7.2 quote.module \quote_form_alter()
  5. 7 quote.module \quote_form_alter()

Implements hook_form_alter().

File

./quote.module, line 115
Allows users to quote posts or comments.

Code

function quote_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if (strpos($form_id, 'comment_') == 0 && isset($_GET['comment-quote-all-reply'])) {
    $comment = \Drupal::entityTypeManager()
      ->getStorage('comment')
      ->load($_GET['comment-quote-all-reply']);
    $config = \Drupal::config('quote.settings');
    $limit = $config
      ->get('quote_limit');
    $comment_limit = substr($comment
      ->get('comment_body')->value, 0, $limit);
    $form['comment_body']['widget']['0']['#default_value'] = '<blockquote><strong>' . t('@author wrote:', [
      '@author' => $comment
        ->getAuthorName(),
    ]) . '</strong> ' . $comment_limit . '</blockquote><p><br/></p>';
  }
}