mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
26 lines
540 B
PHP
26 lines
540 B
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* A class for creating new objects by the injector.
|
||
|
*
|
||
|
* @package framework
|
||
|
* @subpackage injector
|
||
|
*/
|
||
|
class InjectionCreator {
|
||
|
|
||
|
/**
|
||
|
* @param string $object
|
||
|
* A string representation of the class to create
|
||
|
* @param array $params
|
||
|
* An array of parameters to be passed to the constructor
|
||
|
*/
|
||
|
public function create($class, $params = array()) {
|
||
|
$reflector = new ReflectionClass($class);
|
||
|
|
||
|
if (count($params)) {
|
||
|
return $reflector->newInstanceArgs($params);
|
||
|
}
|
||
|
|
||
|
return $reflector->newInstance();
|
||
|
}
|
||
|
}
|