diff --git a/src/NodeJS/Server.php b/src/NodeJS/Server.php index 94c9fb7..32414c8 100644 --- a/src/NodeJS/Server.php +++ b/src/NodeJS/Server.php @@ -60,6 +60,11 @@ abstract class Server */ protected $connection; + /** + * @var array + */ + protected $options = array(); + /** * Constructor * @@ -76,7 +81,8 @@ public function __construct( $nodeBin = null, $serverPath = null, $threshold = 2000000, - $nodeModulesPath = '' + $nodeModulesPath = '', + $options = array() ) { if (null === $nodeBin) { $nodeBin = 'node'; @@ -93,6 +99,8 @@ public function __construct( $this->serverPath = $serverPath; $this->threshold = intval($threshold); + + $this->setOptions($options); } /** @@ -193,6 +201,30 @@ public function getNodeModulesPath() return $this->nodeModulesPath; } + /** + * Return the all options. + * + * @return array + */ + public function getOptions() + { + return $this->options; + } + + /** + * Set options array. + * + * @param array $options Array of options to set. + */ + public function setOptions($options) + { + foreach ($options as $key => $value) { + $this->options[$key] = $value; + } + + $this->serverPath = $this->createTemporaryServer(); + } + /** * Setter server script path * @@ -423,6 +455,7 @@ protected function createTemporaryServer() '%host%' => $this->host, '%port%' => $this->port, '%modules_path%' => $this->nodeModulesPath, + '%options%' => json_encode($this->options), )); $serverPath = tempnam(sys_get_temp_dir(), 'mink_nodejs_server'); diff --git a/src/NodeJS/Server/ZombieServer.php b/src/NodeJS/Server/ZombieServer.php index becc0ba..6e70bcd 100644 --- a/src/NodeJS/Server/ZombieServer.php +++ b/src/NodeJS/Server/ZombieServer.php @@ -173,7 +173,7 @@ protected function getServerScript() stream.on('end', function () { if (browser == null) { - browser = new zombie(); + browser = new zombie(%options%); // Clean up old pointers pointers = [];