Skip to content

Instantly share code, notes, and snippets.

@BBGuy
Last active February 4, 2020 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBGuy/63f34d200499bd8e211b267902d47f9a to your computer and use it in GitHub Desktop.
Save BBGuy/63f34d200499bd8e211b267902d47f9a to your computer and use it in GitHub Desktop.
<?php
// Get the request object.
$request = \Drupal::request();
// Query - get all parameter.
$q = $request->query->all();
// Check if a query parameter exists.
if ($request->query->has('commerce_product_v_id')) {
// Get the query parameter.
$pvid = $request->query->get('commerce_product_v_id');
}
// Drupal messenger (from commerce_stock)
\Drupal::messenger()->addMessage(t('Updated the stock.'));
\Drupal::messenger()->addError(t('The maximum quantity for %name that can be ordered is %qty.', [
'%name' => $name,
'%qty' => $stock_level,
]));
}
@BBGuy
Copy link
Author

BBGuy commented Oct 4, 2016

Working with key/value pairs
reading from the $request uses the symfony ParameterBag a a container for key/value pairs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment