| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
stubClassLoader::load('net::stubbles::ioc::stubBinder', |
|---|
| 10 |
'net::stubbles::lang::stubRegistry', |
|---|
| 11 |
'net::stubbles::lang::exceptions::stubRuntimeException', |
|---|
| 12 |
'net::stubbles::util::log::stubLogData', |
|---|
| 13 |
'net::stubbles::util::log::stubLogger' |
|---|
| 14 |
); |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
class stubLogDataFactory |
|---|
| 23 |
{ |
|---|
| 24 |
|
|---|
| 25 |
* returns the injector instance |
|---|
| 26 |
* |
|---|
| 27 |
* @param stubLogData $logData |
|---|
| 28 |
*/ |
|---|
| 29 |
protected static function handleInjections(stubLogData $logData) |
|---|
| 30 |
{ |
|---|
| 31 |
static $injector; |
|---|
| 32 |
if (null === $injector) { |
|---|
| 33 |
$binder = stubRegistry::get(stubBinder::REGISTRY_KEY); |
|---|
| 34 |
if (($binder instanceof stubBinder) === false) { |
|---|
| 35 |
return; |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
$injector = $binder->getInjector(); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
$injector->handleInjections($logData); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
* creates a stubLogData object |
|---|
| 46 |
* |
|---|
| 47 |
* @param string $target target where the log data should go to |
|---|
| 48 |
* @param int $level optional log level of the log data |
|---|
| 49 |
* @return stubLogData |
|---|
| 50 |
* @throws stubRuntimeException |
|---|
| 51 |
*/ |
|---|
| 52 |
public static function create($target, $level = stubLogger::LEVEL_INFO) |
|---|
| 53 |
{ |
|---|
| 54 |
$fqClassName = stubRegistry::getConfig(stubLogData::CLASS_REGISTRY_KEY, 'net::stubbles::util::log::stubBaseLogData'); |
|---|
| 55 |
$nqClassName = stubClassLoader::getNonQualifiedClassName($fqClassName); |
|---|
| 56 |
if (class_exists($nqClassName, false) === false) { |
|---|
| 57 |
stubClassLoader::load($fqClassName); |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
$logData = new $nqClassName($target, $level); |
|---|
| 61 |
if (($logData instanceof stubLogData) === false) { |
|---|
| 62 |
throw new stubRuntimeException('Configured ' . stubLogData::CLASS_REGISTRY_KEY . ' is not an instance of net::stubbles::util::log::stubLogData.'); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
self::handleInjections($logData); |
|---|
| 66 |
return $logData; |
|---|
| 67 |
} |
|---|
| 68 |
} |
|---|
| 69 |
?> |
|---|