Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit 84c9006

Browse files
committed
Used Josh phantomjs service container for loading config files in provider
1 parent 69e4bca commit 84c9006

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/PhantomJsServiceProvider.php

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@
55
use JonnyW\PhantomJs\Engine;
66
use JonnyW\PhantomJs\Client;
77
use Illuminate\Support\ServiceProvider;
8-
use JonnyW\PhantomJs\DependencyInjection\ServiceContainer;
98

109
class 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

Comments
 (0)