Last active
December 24, 2015 07:09
-
-
Save alnutile/6761754 to your computer and use it in GitHub Desktop.
using switch
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
/** | |
* @param $string | |
* Features should have trailing lines | |
* 1. The benefits | |
* 2. The role of the user | |
* 3. The description | |
* @return array | |
*/ | |
function behat_editor_string_feature($string, $scenario, $count, $direction) { | |
$results = array(); | |
$first_word = _behat_editor_pop_first_word($string); | |
$options = array('Feature:'); | |
drupal_alter('behat_editor_string_feature', $options); | |
if(in_array($first_word, $options)) { | |
switch($direction) { | |
case 'file': | |
$tags = array(); | |
$tags[] = behat_editor_string_tags($scenario, $count - 1, 0, $direction); | |
$feature_line[] = array( | |
'string' => $string, | |
'spaces' => 0, | |
'new_line' => 0, | |
'new_line_above' => 0, | |
); | |
$results['feature'] = $tags + $feature_line; | |
return $results; | |
case 'html_view': | |
$tags = array(); | |
$tags[0] = behat_editor_string_tags($scenario, $count - 1, 0, $direction); | |
$feature_line[] = array( | |
'data' => $string, | |
'class' => array('feature', "spaces-none") | |
); | |
$results['feature'] = $tags + $feature_line; | |
return $results; | |
case 'html_edit': | |
$tags = array(); | |
$tags = behat_editor_string_tags($scenario, $count - 1, 0, $direction); | |
//@todo remove number key should be automatic | |
$features_tags[] = array( | |
'data' => "<strong>Feature Tags:</strong>", | |
'class' => array('ignore'), | |
); | |
$features_tag_input[] = array( | |
'data' => array('features_tag_value' => array('#id' => 'features-tagit-values', '#type' => 'hidden', '#name' => 'features_tag_value', '#value'=>$tags)), | |
'class' => array('tag hidden'), | |
'id' => 'features-tags' | |
); | |
$features_tag_it[] = array( | |
'data' => '<ul id="features-tagit-input"></ul><div class="help-block">Start each tag with @. Just separate by comma for more than one tags. Tags can not have spaces.</div>', | |
'class' => array('ignore'), | |
); | |
$feature_line[] = array( | |
'data' => $string, | |
'class' => array('feature') | |
); | |
$results['feature'] = $features_tags + $features_tag_input + $features_tag_it + $feature_line; | |
return $results; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment