Refactored DependencyFactory for Profiler

This commit is contained in:
Philipp Holzer 2019-02-17 21:12:12 +01:00
commit 5e5c39b0e1
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
12 changed files with 65 additions and 47 deletions

View file

@ -2,24 +2,25 @@
namespace Friendica\Factory;
use Friendica\Core\Config\ConfigCache;
use Friendica\Core\Config\Cache\IConfigCache;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
class ProfilerFactory
{
/**
* Creates a Profiler for the current execution
*
* @param LoggerInterface $logger The logger for saving the profiling data
* @param ConfigCache $configCache The configuration cache
* @param IConfigCache $configCache The configuration cache
*
* @return Profiler
*/
public static function create(LoggerInterface $logger, ConfigCache $configCache)
public static function create(IConfigCache $configCache)
{
$enabled = $configCache->get('system', 'profiler', false);
$renderTime = $configCache->get('rendertime', 'callstack', false);
return new Profiler($logger, $enabled, $renderTime);
$enabled = $configCache->get('system', 'profiler');
$enabled = isset($enabled) && $enabled !== '!<unset>!';
$renderTime = $configCache->get('rendertime', 'callstack');
$renderTime = isset($renderTime) && $renderTime !== '!<unset>!';
return new Profiler($enabled, $renderTime);
}
}