Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / hacked / src / hackedProject.php
index dcd684138a13c232e34b4c2c53f89372e6df2026..33f82e3d20b548b528b8fa82eb7438732cd1388c 100644 (file)
@@ -1,10 +1,5 @@
 <?php
 
-/**
- * @file
- * Contains \Drupal\hacked\hackedProject.
- */
-
 namespace Drupal\hacked;
 
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -49,8 +44,17 @@ class hackedProject {
    * Constructor.
    */
   function __construct($name) {
+    // Identify the project.
     $this->name = $name;
-    $this->remote_files_downloader = new hackedProjectWebFilesDownloader($this);
+    $this->identify_project();
+
+    // Choose an appropriate downloader.
+    if ($this->isDevVersion()) {
+      $this->remote_files_downloader = new hackedProjectWebDevDownloader($this);
+    }
+    else {
+      $this->remote_files_downloader = new hackedProjectWebFilesDownloader($this);
+    }
   }
 
   /**
@@ -110,6 +114,20 @@ class hackedProject {
     }
   }
 
+  /**
+   * Determines if the project is a development version or has an explicit release.
+   *
+   * @return boolean
+   *   TRUE if the project is a dev release; FALSE otherwise.
+   */
+  function isDevVersion() {
+    // Grab the version string.
+    $version = $this->existing_version;
+
+    // Assume we have a dev version if the string ends with "-dev".
+    return (substr_compare($version, '-dev', -4, 4) === 0) ? TRUE : FALSE;
+  }
+
   /**
    * Downloads the remote project to be hashed later.
    */