silverstripe-framework/Core/Manifest/ConfigStaticManifest.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

37 lines
768 B
PHP

<?php
namespace SilverStripe\Core\Manifest;
use ReflectionClass;
/**
* Allows access to config values set on classes using private statics.
*/
class SS_ConfigStaticManifest {
/**
* @param string $class
* @param string $name
* @return mixed
*/
public function get($class, $name) {
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() && $property->isPrivate()) {
$property->setAccessible(true);
return $property->getValue();
}
}
}
}
return null;
}
}