Commit 658fd71c authored by Thiago Pereira's avatar Thiago Pereira Committed by Will Hartmann
Browse files

Issue #3269703 by tmaiochi, Guilherme Rabelo: Fix Code Sniffer Errors & Warnings

parent 26830ed3
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -94,16 +94,16 @@ class WebformEloquaHandler extends WebformHandlerBase {
        'callback' => [$this, 'ajaxCallback'],
        'progress' => [
          'type' => 'throbber',
          'message' => t('Loading fields...'),
          'message' => $this->t('Loading fields...'),
        ],
        'wrapper' => 'field-mapping-wrapper'
        'wrapper' => 'field-mapping-wrapper',
      ],
      '#parents' => ['settings', 'eloqua_form_id']
      '#parents' => ['settings', 'eloqua_form_id'],
    ];

    // Eloqua field mapping:
    // Source  -> destination
    //  webform -> eloqua field
    // webform -> eloqua field.
    $destination_options = [];

    // If we have a form id selected, load all its fields to populate the
@@ -135,11 +135,11 @@ class WebformEloquaHandler extends WebformHandlerBase {
    $form['field_mapping'] = [
      '#type' => 'container',
      '#attributes' => [
        'id' => 'field-mapping-wrapper'
        'id' => 'field-mapping-wrapper',
      ],
    ];

    // Default webform fields
    // Default webform fields.
    $form['field_mapping']['default'] = [
      '#type' => 'details',
      '#title' => $this->t('Default Webform Field Mapping'),
@@ -168,10 +168,10 @@ class WebformEloquaHandler extends WebformHandlerBase {
      '#destination' => $destination_options,
      '#destination__title' => $this->t('Eloqua Field'),
      '#destination__description' => NULL,
      '#parents' => ['settings', 'default_eloqua_field_mapping']
      '#parents' => ['settings', 'default_eloqua_field_mapping'],
    ];

    // User generate webform elements
    // User generate webform elements.
    $form['field_mapping']['user'] = [
      '#type' => 'details',
      '#title' => $this->t('User Field Mapping'),
@@ -201,7 +201,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
      '#destination' => $destination_options,
      '#destination__title' => $this->t('Eloqua Field'),
      '#destination__description' => NULL,
      '#parents' => ['settings', 'user_eloqua_field_mapping']
      '#parents' => ['settings', 'user_eloqua_field_mapping'],
    ];

    return $form;
@@ -215,7 +215,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return
   * @return array
   *   The form element represented by the 'wrapper' attribute in the AJAX
   *   callback settings.
   */
@@ -231,7 +231,6 @@ class WebformEloquaHandler extends WebformHandlerBase {
    $default_field_mapping = $form_state->getValue('default_eloqua_field_mapping');
    $user_field_mapping = $form_state->getValue('user_eloqua_field_mapping');


    // Assert that all required Eloqua fields are mapped.
    $required_eloqua_fields = [];
    $required_eloqua_fields_submitted = [];
@@ -245,7 +244,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
    }

    // Check each field mapping for default webform fields.
    foreach ($default_field_mapping as $webform_element_id => $eloqua_field_id) {
    foreach ($default_field_mapping as $eloqua_field_id) {
      // Does the specified mapping field actually exist?
      if (!array_key_exists($eloqua_field_id, $eloqua_fields)) {
        // Bah, no field with that ID.
@@ -263,7 +262,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
    }

    // Check each field mapping for user webform fields.
    foreach ($user_field_mapping as $webform_element_id => $eloqua_field_id) {
    foreach ($user_field_mapping as $eloqua_field_id) {
      // Does the specified mapping field actually exist?
      if (!array_key_exists($eloqua_field_id, $eloqua_fields)) {
        // Bah, no field with that ID.
@@ -320,7 +319,7 @@ class WebformEloquaHandler extends WebformHandlerBase {

    $forms = [];
    $result = $this->eloquaFormsService->getForms([
      'orderBy' => 'name'
      'orderBy' => 'name',
    ]);

    if (!empty($result['elements'])) {
@@ -418,7 +417,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
   *   The webform submission to be posted.
   */
  protected function remotePost($state, WebformSubmissionInterface $webform_submission) {
    // TODO Maybe make these configurable in the future.
    // @todo Maybe make these configurable in the future.
    $completed = WebformSubmissionInterface::STATE_COMPLETED;
    if ($state != $completed) {
      return;
@@ -445,7 +444,7 @@ class WebformEloquaHandler extends WebformHandlerBase {
    // Submit the form data to Eloqua using the REST API.
    $submission = $this->eloquaFormsService->createFormData($form_id, $form_data);

    // TODO Improve error checking and logging.
    // @todo Improve error checking and logging.
    if (empty($submission)) {
      // Log error message.
      $context = [