Skip to content

Commit

Permalink
custom config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlevi committed Nov 23, 2016
1 parent 70e6da1 commit 35b6e0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/BeEditFeatureManager.php
Expand Up @@ -29,6 +29,9 @@ public function loadSettings() {
drupal_set_message(t('Behat Project Root needs to be set.'), 'error');
}

// Get Behat extra config settings
$this->behatConfig = $config->get('beedit_behat_config');

// Get Drupal temp file path.
$this->drupalTempPath = file_directory_temp();
}
Expand Down
6 changes: 4 additions & 2 deletions src/BehatFeatureManager.php
Expand Up @@ -12,6 +12,7 @@
abstract class BehatFeatureManager implements BehatFeatureManagerInterface {
protected $behatProjectRoot;
protected $behatBin;
protected $behatConfig;
protected $featuresRootPath;
protected $featureFullPath;
protected $sortField;
Expand Down Expand Up @@ -43,14 +44,15 @@ public function __construct($feature_name_subpath = '') {
* Load BeEdit settings..
*
* This method loads configuration settings and updates the variables
* $behatProjectRoot, $behatBin and $drupalTempPath.
* $behatProjectRoot, $behatBin, $behatConfig, and $drupalTempPath.
*
* This method is overridden in the extended class BeEditFeatureManager.php
* to allow for different Drupal versions.
*/
public function loadSettings() {
$this->behatProjectRoot = '';
$this->behatBin = '';
$this->behatConfig = '';
}

/**
Expand Down Expand Up @@ -169,7 +171,7 @@ public function run() {
$filename = "$this->drupalTempPath/beedit_$timestamp.txt";

// Run behat command as a separate process and store output in temp folder.
$command = "cd $this->behatProjectRoot && $this->behatBin --colors 'features/$this->featureName.feature' > $filename & echo $!";
$command = "cd $this->behatProjectRoot && $this->behatBin $this->behatConfig --colors 'features/$this->featureName.feature' > $filename & echo $!";
$pid = exec($command);

return [
Expand Down
10 changes: 10 additions & 0 deletions src/Form/BeEditSettingsForm.php
Expand Up @@ -40,6 +40,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $config->get('beedit_behat_bin'),
];

$form['beedit_behat_config'] = [
'#type' => 'textfield',
'#title' => $this->t('Additional Config Settings'),
'#description' => $this->t('Specify additional paramaters Example: `--config=local.yml -p local`'),
'#default_value' => $config->get('beedit_behat_config'),
];

$form['beedit_behat_project_root'] = [
'#type' => 'textfield',
'#title' => $this->t('Behat Project Folder'),
Expand Down Expand Up @@ -81,6 +88,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$config->set('beedit_behat_project_root', $form_state->getValue('beedit_behat_project_root'))
->save();

$config->set('beedit_behat_config', $form_state->getValue('beedit_behat_config'))
->save();

parent::submitForm($form, $form_state);
}

Expand Down

1 comment on commit 35b6e0b

@justinlevi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enables this additional field:

screen shot 2016-11-23 at 12 10 15 pm

Please sign in to comment.