summaryrefslogtreecommitdiffstats
path: root/admin/survey/minify/lib/Minify/Controller/Base.php
blob: 557b51496a8c8797a3b6e8ddd521da474331812d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
 * Class Minify_Controller_Base
 * @package Minify
 */

use Psr\Log\LoggerInterface;
use Monolog\Logger;

/**
 * Base class for Minify controller
 *
 * The controller class validates a request and uses it to create a configuration for Minify::serve().
 *
 * @package Minify
 * @author Stephen Clay <steve@mrclay.org>
 */
abstract class Minify_Controller_Base implements Minify_ControllerInterface
{

    /**
     * @var Minify_Env
     */
    protected $env;

    /**
     * @var Minify_Source_Factory
     */
    protected $sourceFactory;

    /**
     * @var LoggerInterface
     */
    protected $logger;

    /**
     * @param Minify_Env            $env
     * @param Minify_Source_Factory $sourceFactory
     * @param LoggerInterface       $logger
     */
    public function __construct(Minify_Env $env, Minify_Source_Factory $sourceFactory, LoggerInterface $logger = null)
    {
        $this->env = $env;
        $this->sourceFactory = $sourceFactory;
        if (!$logger) {
            $logger = new Logger('minify');
        }
        $this->logger = $logger;
    }

    /**
     * Create controller sources and options for Minify::serve()
     *
     * @param array $options controller and Minify options
     *
     * @return Minify_ServeConfiguration
     */
    abstract public function createConfiguration(array $options);

    /**
     * Send message to the Minify logger
     *
     * @param string $msg
     *
     * @return null
     * @deprecated use $this->logger
     */
    public function log($msg)
    {
        trigger_error(__METHOD__ . ' is deprecated in Minify 3.0.', E_USER_DEPRECATED);
        $this->logger->info($msg);
    }

    /**
     * {@inheritdoc}
     */
    public function getEnv()
    {
        return $this->env;
    }
}