Skip to content

Commit

Permalink
fix missing class reference
Browse files Browse the repository at this point in the history
  • Loading branch information
NewZeal committed Jun 25, 2018
1 parent 5094934 commit 5e0cd31
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions message_private.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Drupal\message\Entity\Message;
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
use Drupal\Core\Form\FormStateInterface;

use Drupal\Core\StringTranslation\TranslatableMarkup;


/**
Expand Down Expand Up @@ -126,8 +126,18 @@ function message_private_access_callback($message) {
* the message_text on the edit and create form, and adds custom validation.
*/
// @todo - check form ID is matching D8 form id.
function message_private_form_message_private_message_form_alter(&$form, FormStateInterface $form_state, $form_id) {
function message_private_form_message_private_message_form_alter(&$form, FormStateInterface $form_state) {
_message_private_message_form_alter($form, $form_state);
}

function message_private_form_message_private_message_edit_form_alter(&$form, FormStateInterface $form_state) {
_message_private_message_form_alter($form, $form_state);
}

/*
* Helper function to modify message form
*/
function _message_private_message_form_alter(&$form, FormStateInterface $form_state){
$entity = $form_state->getFormObject()->getEntity();
if ($entity->bundle() == 'private_message') {
$form['field_message_private_to_user']['widget']['add_more']['#value'] = new TranslatableMarkup('Add another user');
Expand All @@ -138,15 +148,9 @@ function message_private_form_message_private_message_form_alter(&$form, FormSta
$form['owner']['#access'] = \Drupal::currentUser()->hasPermission('bypass private message access control');

$form['#validate'][] = 'message_private_form_message_private_message_form_validate';
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
$form['actions'][$action]['#submit'][] = 'message_private_message_form_submit';
}
}
}
}


/**
* Validation for Private Message form.
*
Expand Down

0 comments on commit 5e0cd31

Please sign in to comment.