Ejemplo n.º 1
0
Archivo: Plugin.php Proyecto: Jobu/core
 /**
  * Inject the swiftMailer version into the Contao package.
  *
  * @param string          $contaoRoot The Contao root dir.
  *
  * @param CompletePackage $package    The package being processed.
  *
  * @return void
  */
 protected function injectSwiftMailer($contaoRoot, CompletePackage $package)
 {
     $provides = $package->getProvides();
     $versionParser = new VersionParser();
     // detect provided Swift Mailer version
     switch ($this->getContaoVersion()) {
         case '2.11':
             $file = $contaoRoot . '/plugins/swiftmailer/VERSION';
             break;
         case '3.0':
             $file = $contaoRoot . '/system/vendor/swiftmailer/VERSION';
             break;
         case '3.1':
         case '3.2':
             $file = $contaoRoot . '/system/modules/core/vendor/swiftmailer/VERSION';
             break;
         default:
             $file = false;
     }
     if ($file && is_file($file)) {
         $prettySwiftVersion = file_get_contents($file);
         $prettySwiftVersion = substr($prettySwiftVersion, 6);
         $prettySwiftVersion = trim($prettySwiftVersion);
         $swiftVersion = $versionParser->normalize($prettySwiftVersion);
         $swiftConstraint = $this->createConstraint('==', $swiftVersion);
         $swiftConstraint->setPrettyString($swiftVersion);
         $swiftLink = new Link('contao/core', 'swiftmailer/swiftmailer', $swiftConstraint, 'provides', $swiftVersion);
         $provides['swiftmailer/swiftmailer'] = $swiftLink;
     }
     $package->setProvides($provides);
 }