1 | <?php |
||
12 | class PimpleServiceProvider implements ServiceProviderInterface |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | public $session_name; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | public $request_attribute_name; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * @var LoggerInterface |
||
29 | */ |
||
30 | public $logger; |
||
31 | |||
32 | |||
33 | |||
34 | /** |
||
35 | * @param string $session_name The Session (segment) name |
||
36 | * @param string $request_attribute_name PSR7 Request attribute name, defaults to "session" |
||
37 | * @param LoggerInterface $logger Optional: PSR3 Logger instance |
||
38 | */ |
||
39 | public function __construct( $session_name, $request_attribute_name = "session", LoggerInterface $logger = null ) |
||
45 | |||
46 | |||
47 | /** |
||
48 | * @param Container $dic Pimple Container |
||
49 | * @implements ServiceProviderInterface |
||
50 | */ |
||
51 | public function register(Container $dic) |
||
86 | } |
||
87 | |||
88 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: