This repository was archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Support zombie.js options #154
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a17347
Started on allowing Zombie.js options
robballou f57a58e
Merge branch 'master' into zombie-options
robballou 860aaca
Removed option validation, moved options methods, added getOption() w…
robballou ab2a51e
Added createTemporaryServer() call in setOptions()
robballou 80999d8
Removed setOption(), updated setOptions()
robballou 95fa786
Removed getOption()
robballou 847ecea
Updated setOptions() code styles
robballou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,46 @@ public function getNodeModulesPath() | |
| return $this->nodeModulesPath; | ||
| } | ||
|
|
||
| /** | ||
| * Get a single option. | ||
| * | ||
| * @param string $option The option name to retrieve. | ||
| * @param mixed $default_value The value to return if the option is not set. | ||
| * | ||
| * @return mixed The option value or default value if it is not set. | ||
| */ | ||
| public function getOption($option, $default_value = NULL) | ||
| { | ||
| if (!isset($this->options[$option])) { | ||
| return $default_value; | ||
| } | ||
|
|
||
| return $this->options[$option]; | ||
| } | ||
|
|
||
| /** | ||
| * 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(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add empty line above. If you have any automated code style checks in place for PSR2 standard then this should have been reported as error by them. Also the Scrutinizer CI should have picked that as well. |
||
| } | ||
|
|
||
| /** | ||
| * Setter server script path | ||
| * | ||
|
|
@@ -423,6 +471,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'); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this method.
I don't see any potential use of this method, because the only consumer of this options is Zombie itself. Nobody wants to introspect what options current server has.