File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 33
44namespace VCR \VCRBundle ;
55
6+ use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
67use Symfony \Component \Filesystem \Filesystem ;
78use Symfony \Component \HttpKernel \Bundle \Bundle ;
9+ use VCR \Videorecorder ;
810
911class VCRBundle extends Bundle
1012{
@@ -17,12 +19,33 @@ public function boot(): void
1719 $ fs ->mkdir ($ cassettePath );
1820 }
1921
20- if ($ this ->container -> getParameter ( ' vcr.enabled ' )) {
21- $ recorder = $ this ->container -> get ( ' vcr.recorder ' );
22+ if ($ this ->isEnabled ( )) {
23+ $ recorder = $ this ->getVideoRecorder ( );
2224 $ cassetteName = $ this ->container ->getParameter ('vcr.cassette.name ' );
2325
2426 $ recorder ->turnOn ();
2527 $ recorder ->insertCassette ($ cassetteName );
2628 }
2729 }
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+ }
2851}
You can’t perform that action at this time.
0 commit comments