Modified how to re-enable old SS_ConfigStaticManifest to suit the SS config system

This commit is contained in:
Silbinary Wolf 2015-12-29 17:18:10 +11:00 committed by Sam Minnée
parent 65ac23098e
commit 8f65c44865
3 changed files with 70 additions and 73 deletions

View File

@ -78,9 +78,6 @@ require_once 'core/manifest/ManifestCache.php';
require_once 'core/manifest/ClassLoader.php'; require_once 'core/manifest/ClassLoader.php';
require_once 'core/manifest/ConfigManifest.php'; require_once 'core/manifest/ConfigManifest.php';
require_once 'core/manifest/ConfigStaticManifest.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/ClassManifest.php';
require_once 'core/manifest/ManifestFileFinder.php'; require_once 'core/manifest/ManifestFileFinder.php';
require_once 'core/manifest/TemplateLoader.php'; require_once 'core/manifest/TemplateLoader.php';
@ -119,10 +116,10 @@ if(file_exists(BASE_PATH . '/vendor/autoload.php')) {
require_once(BASE_PATH . '/framework/model/fieldtypes/compat/autoload.php'); require_once(BASE_PATH . '/framework/model/fieldtypes/compat/autoload.php');
// Now that the class manifest is up, load the static configuration // Now that the class manifest is up, load the static configuration
if (class_exists('SS_ConfigStaticManifest_40')) { if (defined('SS_USE_OLD_CONFIGSTATICMANIFEST') && SS_USE_OLD_CONFIGSTATICMANIFEST) {
$configManifest = new SS_ConfigStaticManifest_40(BASE_PATH, false, $flush);
} else {
$configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush); $configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush);
} else {
$configManifest = new SS_ConfigStaticManifest_40(BASE_PATH, false, $flush);
} }
Config::inst()->pushConfigStaticManifest($configManifest); Config::inst()->pushConfigStaticManifest($configManifest);

View File

@ -1,4 +1,71 @@
<?php <?php
/**
* Allows access to config values set on classes using private statics.
*
* @package framework
* @subpackage manifest
*/
class SS_ConfigStaticManifest_40 extends SS_ConfigStaticManifest {
/**
* Constructs and initialises a new config static manifest, either loading the data
* from the cache or re-scanning for classes.
*
* @param string $base The manifest base path.
* @param bool $includeTests Include the contents of "tests" directories.
* @param bool $forceRegen Force the manifest to be regenerated.
* @param bool $cache If the manifest is regenerated, cache it.
*/
public function __construct($base, $includeTests = false, $forceRegen = false, $cache = true) {
// Stubbed as these parameters are not needed for the newer SS_ConficStaticManifest version.
}
/**
* Completely regenerates the manifest file.
*/
public function regenerate($cache = true) {
Deprecation::notice('3.3', 'This is no longer available as SS_ConfigStaticManifest now uses Reflection. For backwards compatibility define SS_USE_OLD_CONFIGSTATICMANIFEST in your _ss_environment.php file.');
}
/**
* @param string $class
* @param string $name
* @param null $default
*
* @return mixed|null
*/
public function get($class, $name, $default = null) {
if(class_exists($class)) {
// The config system is case-sensitive so we need to check the exact value
$reflection = new ReflectionClass($class);
if(strcmp($reflection->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. For backwards compatibility define SS_USE_OLD_CONFIGSTATICMANIFEST in your _ss_environment.php file.');
return array();
}
}
/** /**
* A utility class which builds a manifest of the statics defined in all classes, along with their * A utility class which builds a manifest of the statics defined in all classes, along with their
* access levels and values * access levels and values

View File

@ -1,67 +0,0 @@
<?php
/**
* Allows access to config values set on classes using private statics.
*
* @package framework
* @subpackage manifest
*/
class SS_ConfigStaticManifest_40 extends SS_ConfigStaticManifest {
/**
* Constructs and initialises a new config static manifest, either loading the data
* from the cache or re-scanning for classes.
*
* @param string $base The manifest base path.
* @param bool $includeTests Include the contents of "tests" directories.
* @param bool $forceRegen Force the manifest to be regenerated.
* @param bool $cache If the manifest is regenerated, cache it.
*/
public function __construct($base, $includeTests = false, $forceRegen = false, $cache = true) {
// Stubbed as these parameters are not needed for the newer SS_ConficStaticManifest version.
}
/**
* Completely regenerates the manifest file.
*/
public function regenerate($cache = true) {
Deprecation::notice('3.3', 'This is no longer available as SS_ConfigStaticManifest now uses Reflection.');
}
/**
* @param string $class
* @param string $name
* @param null $default
*
* @return mixed|null
*/
public function get($class, $name, $default = null) {
if(class_exists($class)) {
// The config system is case-sensitive so we need to check the exact value
$reflection = new ReflectionClass($class);
if(strcmp($reflection->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();
}
}