2019-02-16 23:11:30 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
|
2019-02-17 21:12:12 +01:00
|
|
|
use Friendica\Core\Config\Cache\IConfigCache;
|
2019-02-16 23:11:30 +01:00
|
|
|
use Friendica\Util\Profiler;
|
|
|
|
|
|
|
|
class ProfilerFactory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Creates a Profiler for the current execution
|
|
|
|
*
|
2019-02-17 21:12:12 +01:00
|
|
|
* @param IConfigCache $configCache The configuration cache
|
2019-02-16 23:11:30 +01:00
|
|
|
*
|
|
|
|
* @return Profiler
|
|
|
|
*/
|
2019-02-17 21:12:12 +01:00
|
|
|
public static function create(IConfigCache $configCache)
|
2019-02-16 23:11:30 +01:00
|
|
|
{
|
2019-02-17 21:12:12 +01:00
|
|
|
$enabled = $configCache->get('system', 'profiler');
|
2019-02-24 13:40:54 +01:00
|
|
|
$enabled = isset($enabled) && $enabled !== '0';
|
2019-02-17 21:12:12 +01:00
|
|
|
$renderTime = $configCache->get('rendertime', 'callstack');
|
2019-02-24 13:40:54 +01:00
|
|
|
$renderTime = isset($renderTime) && $renderTime !== '0';
|
2019-02-17 21:12:12 +01:00
|
|
|
|
|
|
|
return new Profiler($enabled, $renderTime);
|
2019-02-16 23:11:30 +01:00
|
|
|
}
|
|
|
|
}
|