Commit fb41ee05 authored by Bohdan Minich's avatar Bohdan Minich Committed by Bohdan Artemchuk
Browse files

Issue #3261259: Removed vendor directory from the module, removed usage of...

parent e30608b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
    },
    "require": {
        "mailjet/mailjet-apiv3-php": "^1.5",
        "phpmailer/phpmailer": "^5.2.26"
        "phpmailer/phpmailer": "^6.0.7"
    },
    "minimum-stability": "dev"
}
+30 −16
Original line number Diff line number Diff line
@@ -13,24 +13,38 @@ function mailjet_requirements($phase) {
  $requirements = [];

  if ($phase == 'install') {
    $errorData = [

    if (class_exists('PHPMailer')) {
      $mail = new PHPMailer();
    }

    if (empty($mail)) {
      $requirements['mailjet'] = [
        'title' => (string) t('PHPMailer library'),
        'value' => (string) t('Missing'),
        'severity' => REQUIREMENT_ERROR,
      'description' => t('Mailjet module requires the <a href="@phpmailer">PHPMailer Library</a>, which is missing. Download and extract the entire contents of the archive into the %path directory on your server.',
        [
          '@phpmailer' => 'https://github.com/PHPMailer/PHPMailer/archive/v6.0.7.zip',
          '%path' => 'libraries/phpmailer',
        ]
      ),
        'description' => (string) t("Please install the PHPMailer library by executing 'composer update' in your site's root directory."),
      ];

    if (file_exists('libraries/phpmailer/src/PHPMailer.php')) {
        require_once 'libraries/phpmailer/src/PHPMailer.php';
    } elseif (file_exists('../vendor/phpmailer/phpmailer/src/PHPMailer.php')) {
        require_once '../vendor/phpmailer/phpmailer/src/PHPMailer.php';
    } else {
        $requirements['phpmailer'] = $errorData;
    }
    else {
      $required_version = '6.0.7';
      $installed_version = $mail->Version;
      $requirements['mailjet'] = [
        'title' => (string) t('PHPMailer library'),
        'value' => $installed_version,
      ];
      if (!version_compare($installed_version, $required_version, '>=')) {
        $requirements['mailjet']['severity'] = REQUIREMENT_ERROR;
        $requirements['mailjet']['description'] = (string) t("PHPMailer library @version or higher is required. Please install a newer version by executing 'composer update' in your site's root directory.", [
          '@version' => $required_version,
        ]);
      }
      else {
        $requirements['mailjet']['severity'] = REQUIREMENT_OK;
      }
    }
  }

  return $requirements;
}

+0 −5
Original line number Diff line number Diff line
@@ -4,11 +4,6 @@
 * code for Mailjet module
 */

$path = drupal_get_path('module', 'mailjet');

// Autoloading via composer
require_once $path . '/vendor/autoload.php';

use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
+3 −54
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Mail\MailInterface;
use Drupal\Core\Mail\MailFormatHelper;
//use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\PHPMailer;

/**
 * Defines the default Drupal mail backend, using PHP's native mail() function.
@@ -29,7 +29,7 @@ class MailjetMail implements MailInterface {
   * @param array $message
   *   A message array, as described in hook_mail_alter().
   *
   * @return string
   * @return array
   *   The formatted $message.
   */
  public function format(array $message) {
@@ -86,58 +86,7 @@ public function mail(array $message) {
        $body = (string) $rawBody;
    }

//    $path = drupal_get_path('module', 'mailjet');


//    elseif (file_exists($path . '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php')) {
//      require_once $path . '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
//    }

    /**
     * v 5.2.22
     */
    if (file_exists('libraries/phpmailer/PHPMailerAutoload.php')) {
        require_once 'libraries/phpmailer/PHPMailerAutoload.php';
        $mailer = new \PHPMailer;
    }

    /**
     * v ~6.0
     */
    elseif (file_exists('libraries/phpmailer/src/PHPMailer.php')) {
        require_once 'libraries/phpmailer/src/PHPMailer.php';
        require_once 'libraries/phpmailer/src/SMTP.php';
        $mailer = new \PHPMailer\PHPMailer\PHPMailer;
    } elseif (file_exists('../vendor/phpmailer/phpmailer/src/PHPMailer.php')) {
        require_once '../vendor/phpmailer/phpmailer/src/PHPMailer.php';
        require_once 'libraries/phpmailer/src/SMTP.php';
        $mailer = new \PHPMailer\PHPMailer\PHPMailer;
    }else {
        if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) {
                // If the PHPMailer class is not yet auto-loaded, try to load the library
                // using Libraries API, if present.
                if (function_exists('libraries_load')) {

                    $library = libraries_load('phpmailer');
                    if (empty($library) || empty($library['loaded'])) {

                        \Drupal::logger('mailjet')
                                ->notice('Unable to send mail : Libraries API can not load PHPMailer library.');
                        \Drupal::messenger()->addError(t('Unable to send mail: PHPMailer library does not exist.<br /><br />This module requires the PHPMailer library to be downloaded and installed separately. <br/>Get the latest PHPMailer v5 or v6 from the <a href="https://github.com/PHPMailer/PHPMailer/releases" target="_blank">official PHPMailer GitHub page</a>. <br/> Upload the "phpmailer" folder to your server inside
DRUPAL_ROOT/libraries/.'));
                        return FALSE;
                    }
                } else {
                    \Drupal::messenger()->addError(t('Unable to send mail: PHPMailer library does not exist.'));
                    \Drupal::logger('mailjet')
                            ->notice('Unable to send mail: Libraries API and PHPMailer library does not exist.');
                    return FALSE;
                }
            }
        }



    $mailer = new PHPMailer;

    $system_site_config = \Drupal::config('system.site');
    $from_name = $system_site_config->get('name');

vendor/autoload.php

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit9f95350bff734ea50e86827e21cea0b8::getLoader();
Loading