Skip to content
Snippets Groups Projects
Commit 0e15a010 authored by Frankie D's avatar Frankie D Committed by Bálint Nagy
Browse files

Issue #3397818 by FrankieD3: PHP 8.2 has deprecated the creation of dynamic properties

parent 17a5b25a
No related branches found
No related tags found
No related merge requests found
......@@ -20,28 +20,28 @@ class ContactForm extends FormBase {
/**
* The entity type machine name.
*
* @var string
* @var string|null
*/
private $entityType;
/**
* String for the entity ID.
*
* @var string
* @var string|null
*/
private $entityId;
/**
* String for the field name.
*
* @var string
* @var string|null
*/
private $fieldName;
/**
* Array with the field settings.
*
* @var array
* @var array|null
*/
private $fieldSettings;
......@@ -49,10 +49,10 @@ class ContactForm extends FormBase {
* Contact Form constructor.
*/
public function __construct($entityType = NULL, $entityId = NULL, $fieldName = NULL, $fieldSettings = NULL) {
$this->entity_type = $entityType;
$this->entity_id = $entityId;
$this->field_name = $fieldName;
$this->field_settings = $fieldSettings;
$this->entityType = $entityType;
$this->entityId = $entityId;
$this->fieldName = $fieldName;
$this->fieldSettings = $fieldSettings;
}
/**
......@@ -66,9 +66,9 @@ class ContactForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// $this->entity_id = $id;
// $this->entityId = $id;
$user = \Drupal::currentUser();
$emails = email_contact_get_emails_from_field($this->entity_type, $this->entity_id, $this->field_name);
$emails = email_contact_get_emails_from_field($this->entityType, $this->entityId, $this->fieldName);
$form['emails'] = [
'#type' => 'value',
'#value' => serialize($emails),
......@@ -103,7 +103,7 @@ class ContactForm extends FormBase {
'#value' => $this->t('Send e-mail'),
];
if (!empty($this->field_settings['modal'])) {
if (!empty($this->fieldSettings['modal'])) {
$form['submit']['#attributes']['class'][] = 'use-ajax';
$form['submit']['#ajax'] = [
'callback' => [$this, 'ajaxSubmit'],
......@@ -115,7 +115,7 @@ class ContactForm extends FormBase {
}
if (!$form_state->get('settings')) {
$form_state->set('settings', $this->field_settings);
$form_state->set('settings', $this->fieldSettings);
}
return $form;
......@@ -180,21 +180,21 @@ class ContactForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
if (!empty($this->field_settings['modal'])) {
if (!empty($this->fieldSettings['modal'])) {
return;
}
$this->sendMessage($form, $form_state);
$redirect = '/';
if (!empty($this->field_settings['redirection_to'])) {
switch ($this->field_settings['redirection_to']) {
if (!empty($this->fieldSettings['redirection_to'])) {
switch ($this->fieldSettings['redirection_to']) {
case 'current':
$redirect = NULL;
break;
case 'custom':
$redirect = $this->field_settings['custom_path'];
$redirect = $this->fieldSettings['custom_path'];
break;
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment