| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class Minify_Controller_Base |
| 4 |
* @package Minify |
| 5 |
*/ |
| 6 |
|
| 7 |
use Psr\Log\LoggerInterface; |
| 8 |
use Monolog\Logger; |
| 9 |
|
| 10 |
/** |
| 11 |
* Base class for Minify controller |
| 12 |
* |
| 13 |
* The controller class validates a request and uses it to create a configuration for Minify::serve(). |
| 14 |
* |
| 15 |
* @package Minify |
| 16 |
* @author Stephen Clay <steve@mrclay.org> |
| 17 |
*/ |
| 18 |
abstract class Minify_Controller_Base implements Minify_ControllerInterface |
| 19 |
{ |
| 20 |
|
| 21 |
/** |
| 22 |
* @var Minify_Env |
| 23 |
*/ |
| 24 |
protected $env; |
| 25 |
|
| 26 |
/** |
| 27 |
* @var Minify_Source_Factory |
| 28 |
*/ |
| 29 |
protected $sourceFactory; |
| 30 |
|
| 31 |
/** |
| 32 |
* @var LoggerInterface |
| 33 |
*/ |
| 34 |
protected $logger; |
| 35 |
|
| 36 |
/** |
| 37 |
* @param Minify_Env $env |
| 38 |
* @param Minify_Source_Factory $sourceFactory |
| 39 |
* @param LoggerInterface $logger |
| 40 |
*/ |
| 41 |
public function __construct(Minify_Env $env, Minify_Source_Factory $sourceFactory, ?LoggerInterface $logger = null) |
| 42 |
{ |
| 43 |
$this->env = $env; |
| 44 |
$this->sourceFactory = $sourceFactory; |
| 45 |
if (!$logger) { |
| 46 |
$logger = new Logger('minify'); |
| 47 |
} |
| 48 |
$this->logger = $logger; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Create controller sources and options for Minify::serve() |
| 53 |
* |
| 54 |
* @param array $options controller and Minify options |
| 55 |
* |
| 56 |
* @return Minify_ServeConfiguration |
| 57 |
*/ |
| 58 |
abstract public function createConfiguration(array $options); |
| 59 |
|
| 60 |
/** |
| 61 |
* Send message to the Minify logger |
| 62 |
* |
| 63 |
* @param string $msg |
| 64 |
* |
| 65 |
* @return null |
| 66 |
* @deprecated use $this->logger |
| 67 |
*/ |
| 68 |
public function log($msg) |
| 69 |
{ |
| 70 |
trigger_error(__METHOD__ . ' is deprecated in Minify 3.0.', E_USER_DEPRECATED); |
| 71 |
$this->logger->info($msg); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* {@inheritdoc} |
| 76 |
*/ |
| 77 |
public function getEnv() |
| 78 |
{ |
| 79 |
return $this->env; |
| 80 |
} |
| 81 |
} |
| 82 |
|