sample refactor CMS code out of core
authorEileen McNaughton <eileen@fuzion.co.nz>
Fri, 30 May 2014 08:23:58 +0000 (20:23 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Fri, 30 May 2014 08:23:58 +0000 (20:23 +1200)
CRM/Core/Error.php
CRM/Utils/System/Base.php
CRM/Utils/System/Joomla.php

index a1c196578ddfe7e7772334e7ca7afecd1104af91..f11d4ba618854b1c090c83970df440c5284c2283 100644 (file)
@@ -385,19 +385,7 @@ class CRM_Core_Error extends PEAR_ErrorStack {
 
     CRM_Core_Error::debug_var('Fatal Error Details', $vars);
     CRM_Core_Error::backtrace('backTrace', TRUE);
-    $content = $template->fetch($config->fatalErrorTemplate);
-    // JErrorPage exists only in 3.x and not 2.x
-    // CRM-13714
-    if ($config->userFramework == 'Joomla' && class_exists('JErrorPage')) {
-      $error = new Exception($content);
-      JErrorPage::render($error);
-    }
-    else if ($config->userFramework == 'Joomla' && class_exists('JError')) {
-      JError::raiseError('CiviCRM-001', $content);
-    }
-    else {
-      echo CRM_Utils_System::theme($content);
-    }
+    $config->userSystem->outputError($template->fetch($config->fatalErrorTemplate));
 
     self::abend(CRM_Core_Error::FATAL_ERROR);
   }
index 1aa78eb0bbc6f3b83bb81f27480f9d6ec31402ee..b6091a5cde5922b29b2eba9ec3024895c2424ae9 100644 (file)
@@ -312,5 +312,13 @@ abstract class CRM_Utils_System_Base {
   function checkPermissionAddUser() {
     return FALSE;
   }
+
+  /**
+   * output code from error function
+   * @param string $content
+   */
+  function outputError($content) {
+    echo CRM_Utils_System::theme($content);
+  }
 }
 
index e7d8a4765bdc4a431ad6704c4e4ce4b39b1a7ad6..613cb5d5a9ed4f3216928d61f9da96adaa2063a1 100644 (file)
@@ -826,5 +826,22 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
       return TRUE;
     }
   }
+
+  /**
+   * output code from error function
+   * @param string $content
+   */
+  function outputError($content) {
+    if (class_exists('JErrorPage')) {
+      $error = new Exception($content);
+      JErrorPage::render($error);
+    }
+    else if (class_exists('JError')) {
+      JError::raiseError('CiviCRM-001', $content);
+    }
+    else {
+      parent::outputError($content);
+    }
+  }
 }