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

Commit

Permalink
Used Josh phantomjs service container for loading config files in pro…
Browse files Browse the repository at this point in the history
…vider
  • Loading branch information
mrjosh committed Dec 24, 2017
1 parent 69e4bca commit 84c9006
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/PhantomJsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@
use JonnyW\PhantomJs\Engine;
use JonnyW\PhantomJs\Client;
use Illuminate\Support\ServiceProvider;
use JonnyW\PhantomJs\DependencyInjection\ServiceContainer;

class PhantomJsServiceProvider extends ServiceProvider
{
/**
* Service provider
*
* @var PhantomJsServiceContainer
*/
protected $container;

/**
* PhantomJsServiceProvider constructor.
* Set service container
*
* @param $app
*/
public function __construct($app)
{
parent::__construct($app);

$this->container = $this->getServiceContainer();
}

/**
* Publish config file
*
Expand All @@ -32,13 +51,11 @@ public function register()
{
$this->app->singleton('phantomjs', function(){

$serviceContainer = $this->getServiceContainer();

return new Client(
$serviceContainer->get('engine'),
$serviceContainer->get('procedure_loader'),
$serviceContainer->get('procedure_compiler'),
$serviceContainer->get('message_factory')
$this->container->get('engine'),
$this->container->get('procedure_loader'),
$this->container->get('procedure_compiler'),
$this->container->get('message_factory')
);
});
}
Expand Down Expand Up @@ -82,11 +99,11 @@ protected function getEngine()
*
* @author Alireza Josheghani <josheghani.dev@gmail.com>
* @since 8 May 2017
* @return Client
* @return PhantomJsServiceContainer
*/
protected function getServiceContainer()
{
$serviceContainer = ServiceContainer::getInstance();
$serviceContainer = PhantomJsServiceContainer::getInstance();

$serviceContainer->set('engine', $this->getEngine());

Expand Down

0 comments on commit 84c9006

Please sign in to comment.