2013-02-26 04:44:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2015-05-01 03:04:55 +02:00
|
|
|
* Allows access to config values set on classes using private statics.
|
2013-11-29 05:12:47 +01:00
|
|
|
*
|
|
|
|
* @package framework
|
|
|
|
* @subpackage manifest
|
2013-02-26 04:44:48 +01:00
|
|
|
*/
|
2015-05-01 03:04:55 +02:00
|
|
|
class SS_ConfigStaticManifest {
|
2013-02-26 04:44:48 +01:00
|
|
|
|
2014-05-05 12:55:59 +02:00
|
|
|
/**
|
2015-05-01 03:04:55 +02:00
|
|
|
* @param string $class
|
|
|
|
* @param string $name
|
|
|
|
* @param null $default
|
2014-05-05 12:55:59 +02:00
|
|
|
*
|
2015-05-01 03:04:55 +02:00
|
|
|
* @return mixed|null
|
2013-02-26 04:44:48 +01:00
|
|
|
*/
|
2015-05-01 03:04:55 +02:00
|
|
|
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('4.0', "Config static $class::\$$name must be marked as private",
|
|
|
|
Deprecation::SCOPE_GLOBAL);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$property->setAccessible(true);
|
|
|
|
return $property->getValue();
|
2013-06-26 05:49:00 +02:00
|
|
|
}
|
2013-02-26 04:44:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2015-05-01 03:04:55 +02:00
|
|
|
return null;
|
2013-02-26 04:44:48 +01:00
|
|
|
}
|
2013-05-05 02:19:31 +02:00
|
|
|
}
|