/settings.diff Secret
Created
October 14, 2016 12:06
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/CRM/Utils/PhpData.php b/CRM/Utils/PhpData.php | |
new file mode 100644 | |
index 0000000..0f3cac9 | |
--- /dev/null | |
+++ b/CRM/Utils/PhpData.php | |
@@ -0,0 +1,58 @@ | |
+<?php | |
+ | |
+/** | |
+ * Read/write a serialized data file based on PHP's var_export() format | |
+ * | |
+ * @code | |
+ * $data = CRM_Utils_PhpData::create('/tmp/example.php')->load(); | |
+ * CRM_Utils_PhpData::create('/tmp/example.php')->save($data); | |
+ * @endCode | |
+ */ | |
+class CRM_Utils_PhpData { | |
+ | |
+ /** | |
+ * @var string | |
+ */ | |
+ protected $path; | |
+ | |
+ /** | |
+ * @var | |
+ */ | |
+ protected $header; | |
+ | |
+ public function __construct($path, $header = NULL) { | |
+ $this->path = $path; | |
+ $this->header = $header; | |
+ } | |
+ | |
+ /** | |
+ * @param string $path | |
+ * @param string|NULL $header | |
+ * @return \CRM_Utils_PhpData | |
+ */ | |
+ public static function create($path, $header = NULL) { | |
+ return new CRM_Utils_PhpData($path, $header); | |
+ } | |
+ | |
+ /** | |
+ * Read from file | |
+ */ | |
+ public function load() { | |
+ return include $this->path; | |
+ } | |
+ | |
+ /** | |
+ * Write the xml document | |
+ */ | |
+ public function save($data) { | |
+ $content = "<?php\n"; | |
+ if ($this->header) { | |
+ $content .= $this->header; | |
+ } | |
+ $content .= "\nreturn "; | |
+ $content .= var_export($data, TRUE); | |
+ $content .= ";"; | |
+ file_put_contents($this->path, $content); | |
+ } | |
+ | |
+} | |
diff --git a/templates/CRM/common/civicrm.settings.php.template b/templates/CRM/common/civicrm.settings.php.template | |
index 44f2d7b..6216e60 100644 | |
--- a/templates/CRM/common/civicrm.settings.php.template | |
+++ b/templates/CRM/common/civicrm.settings.php.template | |
@@ -419,6 +419,13 @@ if (CIVICRM_UF === 'UnitTests') { | |
if (!defined('CIVICRM_MYSQL_STRICT')) define('CIVICRM_MYSQL_STRICT', true); | |
} | |
+if (file_exists(__DIR__ . '/civicrm.settings.extra.php')) { | |
+ $data = require_once __DIR__ . '/civicrm.settings.extra.php'; | |
+ foreach ($data['define'] as $key => $value) { | |
+ if (!defined($key)) define($key, $value); | |
+ } | |
+} | |
+ | |
/** | |
* | |
* Do not change anything below this line. Keep as is |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I implement this code onto a 4.7 CiviCRM, WordPress installation. I need to add the extra "CiviCRM in it's own directory" feature.