1: <?php
2:
3: namespace PHPFastCGI\FastCGIDaemon\ConnectionHandler;
4:
5: use PHPFastCGI\FastCGIDaemon\Connection\ConnectionInterface;
6: use PHPFastCGI\FastCGIDaemon\CallbackWrapper;
7: use PHPFastCGI\FastCGIDaemon\KernelInterface;
8: use Psr\Log\LoggerAwareInterface;
9: use Psr\Log\LoggerAwareTrait;
10: use Psr\Log\LoggerInterface;
11: use Psr\Log\NullLogger;
12:
13: 14: 15:
16: class ConnectionHandlerFactory implements ConnectionHandlerFactoryInterface, LoggerAwareInterface
17: {
18: use LoggerAwareTrait;
19:
20: 21: 22:
23: private $kernel;
24:
25: 26: 27: 28: 29: 30:
31: public function __construct($kernel, LoggerInterface $logger = null)
32: {
33: $this->setLogger((null === $logger) ? new NullLogger() : $logger);
34:
35: if ($kernel instanceof KernelInterface) {
36: $this->kernel = $kernel;
37: } else {
38: $this->kernel = new CallbackWrapper($kernel);
39: }
40: }
41:
42: 43: 44:
45: public function createConnectionHandler(ConnectionInterface $connection)
46: {
47: return new ConnectionHandler($this->kernel, $connection, $this->logger);
48: }
49: }
50: