Merge pull request #17049 from eileenmcnaughton/phone_array
[civicrm-core.git] / Civi / Core / AssetBuilder.php
index a53be59402aacd8783be82c73e45c79f1e3f3453..82e2141461b1e15e8ab74ce669683b9eac168a0a 100644 (file)
@@ -226,9 +226,11 @@ class AssetBuilder {
 
   /**
    * Clear out any cache files.
+   *
+   * @param bool $removeDir Should folder itself be removed too.
    */
-  public function clear() {
-    \CRM_Utils_File::cleanDir($this->getCachePath());
+  public function clear($removeDir = TRUE) {
+    \CRM_Utils_File::cleanDir($this->getCachePath(), $removeDir);
   }
 
   /**
@@ -342,17 +344,7 @@ class AssetBuilder {
   public static function pageRun() {
     // Beg your pardon, sir. Please may I have an HTTP response class instead?
     $asset = self::pageRender($_GET);
-    if (function_exists('http_response_code')) {
-      // PHP 5.4+
-      http_response_code($asset['statusCode']);
-    }
-    else {
-      header('X-PHP-Response-Code: ' . $asset['statusCode'], TRUE, $asset['statusCode']);
-    }
-
-    header('Content-Type: ' . $asset['mimeType']);
-    echo $asset['content'];
-    \CRM_Utils_System::civiExit();
+    \CRM_Utils_System::sendResponse(new \GuzzleHttp\Psr7\Response($asset['statusCode'], ['Content-Type' => $asset['mimeType']], $asset['content']));
   }
 
   /**