File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
namespace VCR \VCRBundle ;
5
5
6
+ use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
6
7
use Symfony \Component \Filesystem \Filesystem ;
7
8
use Symfony \Component \HttpKernel \Bundle \Bundle ;
9
+ use VCR \Videorecorder ;
8
10
9
11
class VCRBundle extends Bundle
10
12
{
@@ -17,12 +19,33 @@ public function boot(): void
17
19
$ fs ->mkdir ($ cassettePath );
18
20
}
19
21
20
- if ($ this ->container -> getParameter ( ' vcr.enabled ' )) {
21
- $ recorder = $ this ->container -> get ( ' vcr.recorder ' );
22
+ if ($ this ->isEnabled ( )) {
23
+ $ recorder = $ this ->getVideoRecorder ( );
22
24
$ cassetteName = $ this ->container ->getParameter ('vcr.cassette.name ' );
23
25
24
26
$ recorder ->turnOn ();
25
27
$ recorder ->insertCassette ($ cassetteName );
26
28
}
27
29
}
30
+
31
+ public function shutdown (): void
32
+ {
33
+ if ($ this ->isEnabled ()) {
34
+ $ this ->getVideoRecorder ()->turnOff ();
35
+ }
36
+ }
37
+
38
+ private function isEnabled (): bool
39
+ {
40
+ try {
41
+ return $ this ->container ->getParameter ('vcr.enabled ' );
42
+ } catch (InvalidArgumentException $ e ) {
43
+ return false ;
44
+ }
45
+ }
46
+
47
+ private function getVideoRecorder (): Videorecorder
48
+ {
49
+ return $ this ->container ->get ('vcr.recorder ' );
50
+ }
28
51
}
You can’t perform that action at this time.
0 commit comments