Last active
February 4, 2020 17:42
-
-
Save BBGuy/63f34d200499bd8e211b267902d47f9a to your computer and use it in GitHub Desktop.
This file contains 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
<?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, | |
])); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working with key/value pairs
reading from the $request uses the symfony ParameterBag a a container for key/value pairs