Pass Context Parameters to Behat's FeatureContext Class

As I sit here now, this has eaten eight hours of my life. Possibly because Google hates me.

Working with Behat and DrupalExtension, I noticed a docblock above my FeatureContext class' __construct method that said:

<?php
  
/**
   * Initializes context.
   *
   * Every scenario gets it's own context object.
   *
   * @param array $parameters
   *   context parameters (set them up through behat.yml)
   */
?>

Well, my head went spinning! If I could set certain variables, I could do this and that and the other; all of which I've completely forgotten in my eight hour quest to figure out how to set the f**king context variables for behat. Lemme tell you, if it's in the docs for Behat or DrupalExtension, I've bloody well missed it. Six times over. What's frustrating is how f**king simple this turned out to be and no one seems to have documented it. And no, by far, I'm not the only Behat / Drupal / DrupalExtension user out there. Here's the update to your behat.yml, assuming you start out with something like this:

default:
  paths:
    features: 'features'
  extensions:
    Behat\MinkExtension\Extension:
      goutte: ~
      selenium2: ~
      base_url: http://mysite.url
      show_cmd: 'open -a Firefox.app %s'
      files_path: /path/to/uploadable/files
    Drupal\DrupalExtension\Extension:
      blackbox: ~
      drush:
        root: /path/to/drupal/web/root
      api_driver: drush
      region_map:
        header: ".container-header"
        content: ".container-main"
        page_title: "span.page-title__inner"
      selectors:
        message_selector: ".messages"
        error_message_selector: ".messages.error"
        success_message_selector: ".messages.status"

Here's the bit to add, right at the beginning::

default:
  context:
    class: "FeatureContext"
    parameters:
      kitchen: "sink"

This will pass an array of parameters to your FeatureContext constructor which, then, become usable within your class. Hope you find this useful. Please excuse my foul language.