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

Commit 69e4bca

Browse files
committed
For some reason we have to create our own service container for using in laravel
We have to create an object to load phantomjs config files in laravel i hope this problem gonna fix in main repo and we can use and enjoy. :)
1 parent a1be098 commit 69e4bca

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/PhantomJsServiceContainer.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Josh\Component\PhantomJs;
4+
5+
use Symfony\Component\Config\FileLocator;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
8+
9+
/**
10+
* PHP PhantomJs
11+
*
12+
* For some reasons i haveto create an object to load phantomjs config files in laravel
13+
* i hope this problem gonna fix in main repo and we can use and enjoy. :)
14+
*
15+
* @author Alireza Josheghani <josheghani.dev@gmail.com>
16+
*/
17+
class PhantomJsServiceContainer extends ContainerBuilder
18+
{
19+
/**
20+
* Service container instance
21+
*
22+
* @var \JonnyW\PhantomJs\DependencyInjection\ServiceContainer
23+
* @access private
24+
*/
25+
private static $instance;
26+
27+
/**
28+
* Get singleton instance
29+
*
30+
* @access public
31+
* @return PhantomJsServiceContainer
32+
*/
33+
public static function getInstance()
34+
{
35+
if (!self::$instance instanceof PhantomJsServiceContainer) {
36+
37+
self::$instance = new PhantomJsServiceContainer();
38+
self::$instance->load();
39+
}
40+
41+
return self::$instance;
42+
}
43+
44+
/**
45+
* Load service container.
46+
*
47+
* @access public
48+
* @param null $file
49+
* @return void
50+
*/
51+
public function load($file = null)
52+
{
53+
$loader = new YamlFileLoader($this, new FileLocator(__DIR__.'/../Resources/config'));
54+
$loader->load('config.yml');
55+
$loader->load('services.yml');
56+
57+
$this->setParameter('phantomjs.cache_dir', sys_get_temp_dir());
58+
$this->setParameter('phantomjs.resource_dir', __DIR__.'/../Resources');
59+
}
60+
}

0 commit comments

Comments
 (0)