From 65ac23098e8722699ec23a0d2936c2e5b0f280f6 Mon Sep 17 00:00:00 2001 From: Silbinary Wolf Date: Sat, 26 Dec 2015 20:06:52 +1100 Subject: [PATCH] Adds support for using the newer ConfigStaticManifest from the 4.0/master branch. If the developer is doing something weird that involves accessing the 'getStatics()', they can simply delete the ConfigStaticManifest40.php file to bring back full compatibility. My reasoning for this addition is that it reduces the /dev/build process greatly and increases the programmers productivity and improves their quality of life (in my opinion anyway, less waiting for 7-12s for private static changes). I'm thinking this should go into 3.3. --- core/Core.php | 9 +++- core/manifest/ConfigStaticManifest40.php | 67 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 core/manifest/ConfigStaticManifest40.php diff --git a/core/Core.php b/core/Core.php index 8d6efe463..bf1f61f96 100644 --- a/core/Core.php +++ b/core/Core.php @@ -78,6 +78,9 @@ require_once 'core/manifest/ManifestCache.php'; require_once 'core/manifest/ClassLoader.php'; require_once 'core/manifest/ConfigManifest.php'; require_once 'core/manifest/ConfigStaticManifest.php'; +if (file_exists('core/manifest/ConfigStaticManifest40.php')) { + require_once 'core/manifest/ConfigStaticManifest40.php'; +} require_once 'core/manifest/ClassManifest.php'; require_once 'core/manifest/ManifestFileFinder.php'; require_once 'core/manifest/TemplateLoader.php'; @@ -116,7 +119,11 @@ if(file_exists(BASE_PATH . '/vendor/autoload.php')) { require_once(BASE_PATH . '/framework/model/fieldtypes/compat/autoload.php'); // Now that the class manifest is up, load the static configuration -$configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush); +if (class_exists('SS_ConfigStaticManifest_40')) { + $configManifest = new SS_ConfigStaticManifest_40(BASE_PATH, false, $flush); +} else { + $configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush); +} Config::inst()->pushConfigStaticManifest($configManifest); // And then the yaml configuration diff --git a/core/manifest/ConfigStaticManifest40.php b/core/manifest/ConfigStaticManifest40.php new file mode 100644 index 000000000..4c222c935 --- /dev/null +++ b/core/manifest/ConfigStaticManifest40.php @@ -0,0 +1,67 @@ +name, $class) === 0) { + + if($reflection->hasProperty($name)) { + $property = $reflection->getProperty($name); + if($property->isStatic()) { + if(!$property->isPrivate()) { + Deprecation::notice('3.3', "Config static $class::\$$name must be marked as private", + Deprecation::SCOPE_GLOBAL); + return null; + } + $property->setAccessible(true); + return $property->getValue(); + } + } + + } + } + return null; + } + + public function getStatics() { + Deprecation::notice('3.3', 'This is no longer available as SS_ConfigStaticManifest now uses Reflection.'); + return array(); + } +} \ No newline at end of file