55use JonnyW \PhantomJs \Engine ;
66use JonnyW \PhantomJs \Client ;
77use Illuminate \Support \ServiceProvider ;
8- use JonnyW \PhantomJs \DependencyInjection \ServiceContainer ;
98
109class PhantomJsServiceProvider extends ServiceProvider
1110{
11+ /**
12+ * Service provider
13+ *
14+ * @var PhantomJsServiceContainer
15+ */
16+ protected $ container ;
17+
18+ /**
19+ * PhantomJsServiceProvider constructor.
20+ * Set service container
21+ *
22+ * @param $app
23+ */
24+ public function __construct ($ app )
25+ {
26+ parent ::__construct ($ app );
27+
28+ $ this ->container = $ this ->getServiceContainer ();
29+ }
30+
1231 /**
1332 * Publish config file
1433 *
@@ -32,13 +51,11 @@ public function register()
3251 {
3352 $ this ->app ->singleton ('phantomjs ' , function (){
3453
35- $ serviceContainer = $ this ->getServiceContainer ();
36-
3754 return new Client (
38- $ serviceContainer ->get ('engine ' ),
39- $ serviceContainer ->get ('procedure_loader ' ),
40- $ serviceContainer ->get ('procedure_compiler ' ),
41- $ serviceContainer ->get ('message_factory ' )
55+ $ this -> container ->get ('engine ' ),
56+ $ this -> container ->get ('procedure_loader ' ),
57+ $ this -> container ->get ('procedure_compiler ' ),
58+ $ this -> container ->get ('message_factory ' )
4259 );
4360 });
4461 }
@@ -82,11 +99,11 @@ protected function getEngine()
8299 *
83100 * @author Alireza Josheghani <josheghani.dev@gmail.com>
84101 * @since 8 May 2017
85- * @return Client
102+ * @return PhantomJsServiceContainer
86103 */
87104 protected function getServiceContainer ()
88105 {
89- $ serviceContainer = ServiceContainer ::getInstance ();
106+ $ serviceContainer = PhantomJsServiceContainer ::getInstance ();
90107
91108 $ serviceContainer ->set ('engine ' , $ this ->getEngine ());
92109
0 commit comments