2013-02-26 04:44:48 +01:00
|
|
|
<?php
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
namespace SilverStripe\Core\Manifest;
|
|
|
|
|
|
|
|
use ReflectionClass;
|
|
|
|
|
2013-02-26 04:44:48 +01:00
|
|
|
/**
|
2015-05-01 03:04:55 +02:00
|
|
|
* Allows access to config values set on classes using private statics.
|
2013-02-26 04:44:48 +01:00
|
|
|
*/
|
2016-09-09 08:43:05 +02:00
|
|
|
class 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
|
2016-08-19 00:51:35 +02:00
|
|
|
* @return mixed
|
2013-02-26 04:44:48 +01:00
|
|
|
*/
|
2016-08-19 00:51:35 +02:00
|
|
|
public function get($class, $name) {
|
2015-05-01 03:04:55 +02:00
|
|
|
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);
|
2016-08-19 00:51:35 +02:00
|
|
|
if($property->isStatic() && $property->isPrivate()) {
|
2015-05-01 03:04:55 +02:00
|
|
|
$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
|
|
|
}
|