dharmeshbarot â created an issue.
Hello,
#34 works for drupal 9 also.
Hello @rudrakumar188,
Can you specify what kind of error you face?
In your post method, you are trying to access the POST data via the $data parameter. However, to retrieve data from the POST request body, you need to use the Request object. Here's how you can modify your code to access the POST data
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;
// ...
/**
* Responds to POST requests.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @return \Drupal\rest\ModifiedResourceResponse
* The HTTP response object.
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* Throws exception if needed.
*/
public function post(Request $request) {
// Retrieve POST data from the request body.
$data = json_decode($request->getContent(), TRUE);
if ($data === null) {
throw new HttpException(400, 'Invalid JSON data in the request body');
}
// Now, you can access and work with the $data array.
// Example: Print the data to the log.
\Drupal::logger('your_module')->notice('Received POST data: ' . print_r($data, TRUE));
// Implement your custom logic here.
// Return a response.
return new ModifiedResourceResponse('Response data');
}
dharmeshbarot â made their first commit to this issueâs fork.
dharmeshbarot â made their first commit to this issueâs fork.
dharmeshbarot â made their first commit to this issueâs fork.
MR 2! is empty that's why it's generating an error, try to merge MR 1!
dharmeshbarot â made their first commit to this issueâs fork.
dharmeshbarot â made their first commit to this issueâs fork.
dharmeshbarot â made their first commit to this issueâs fork.
Following the merge request(41c9b644) solving the error. moving to RTBC
Getting error while installing the module
dharmeshbarot â made their first commit to this issueâs fork.
working
dharmeshbarot â made their first commit to this issueâs fork.
Try this patch..! needs a review
sorry for creating a fork for this issue!
dharmeshbarot â made their first commit to this issueâs fork.
dharmeshbarot â made their first commit to this issueâs fork.
created MR! for this issue and made changes that were told by @Anybody
I think this patch will resolve all errors.
Working on it!
dharmeshbarot â made their first commit to this issueâs fork.
I think this may work!
dharmeshbarot â made their first commit to this issueâs fork.
function mymodule_cron() {
$query = \Drupal::entityQuery('webform_submission')
->condition('webform_id', 'mywebform')
->sort('created', 'ASC')
->accessCheck(FALSE);
$result = $query->execute();
$storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
$submissions = $storage->loadMultiple($result);
foreach ($submissions as $submission) {
$user_id = $submission->getOwnerId();
$user = \Drupal\user\Entity\User::load($user_id);
// Récupération des champs utilisateurs.
$sp = $user->field_situation_p->value;
$sf = $user->field_situation_f->value;
$cua = $user->field_cua->target_id;
// Load the full submission entity object to be able to modify its fields.
$full_submission = $storage->load($submission->id());
if (!empty($sp)) {
$full_submission->setElementData('sp', $sp);
}
if (!empty($sf)) {
$full_submission->setElementData('sf', $sf);
}
if (!empty($cua)) {
$full_submission->setElementData('cua', $cua);
}
// Preserve the original changed timestamp by explicitly setting it again.
$full_submission->set('changed', $submission->getChangedTime());
// Call save() to persist the changes to the submission entity.
$full_submission->save();
}
}
function mymodule_cron() {
$query = \Drupal::entityQuery('webform_submission')
->condition('webform_id', 'mywebform')
->sort('created', 'ASC')
->accessCheck(FALSE);
$result = $query->execute();
$storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
$submissions = $storage->loadMultiple($result);
foreach ($submissions as $submission) {
$user_id = $submission->getOwnerId();
$user = \Drupal\user\Entity\User::load($user_id);
// Récupération des champs utilisateurs.
$sp = $user->field_situation_p->value;
$sf = $user->field_situation_f->value;
$cua = $user->field_cua->target_id;
// Store the original changed timestamp before modifying the submission data.
$originalChangedTime = $submission->getChangedTime();
if (!empty($sp)) {
$submission->setElementData('sp', $sp);
}
if (!empty($sf)) {
$submission->setElementData('sf', $sf);
}
if (!empty($cua)) {
$submission->setElementData('cua', $cua);
}
// Restore the original changed timestamp before saving the submission.
$submission->setChangedTime($originalChangedTime);
$submission->save();
}
}
Try this if it's work.
function mymodule_cron() {
$query = \Drupal::entityQuery('webform_submission')
->condition('webform_id', 'mywebform')
->sort('created', 'ASC')
->accessCheck(FALSE);
$result = $query->execute();
$storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
$submissions = $storage->loadMultiple($result);
foreach ($submissions as $submission) {
$user_id = $submission->getOwnerId();
$user = \Drupal\user\Entity\User::load($user_id);
// Récupération des champs utilisateurs.
$sp = $user->field_situation_p->value;
$sf = $user->field_situation_f->value;
$cua = $user->field_cua->target_id;
if (!empty($sp)) {
$submission->set('elements.sp', $sp);
}
if (!empty($sf)) {
$submission->set('elements.sf', $sf);
}
if (!empty($cua)) {
$submission->set('elements.cua', $cua);
}
$submission->save();
}
}
dharmeshbarot â made their first commit to this issueâs fork.
The MR! working fine! Moving to RTBC
minor changes are implemented to the README.md file
dharmeshbarot â made their first commit to this issueâs fork.
Created MR!
needs review
There is no content in the README.txt file so we need to add content about how this module works.
I made your changes in this branch also 3319902-replace-readme.txt-with
Thanks, @Manoj Raj.R
Did you review my MR? @Manoj Raj.R
Patch #1 was applied successfully and working fine! moving to RTBC
dharmeshbarot â made their first commit to this issueâs fork.
Created MR!
please review it
dharmeshbarot â made their first commit to this issueâs fork.
@saket-001, you have to enable(install) the module to see the help functionality.
Created MR for the issue.
Please review.
dharmeshbarot â made their first commit to this issueâs fork.
I made changes in the Readme file as the name of the module in the .info file.
working on it
made changes to the .module file and README file
Patch #2 was applied successfully and working fine! moving to RTBC
I made some changes in .module file and removed the configuration and usage section from it and push code in responsive_image_preload-3346413 (2.0.x) and now it's working fine
And also we need to update the README.md file content in drupal standard
Patch #2 was applied successfully and working fine, I think we need more detail about how the module works and what to do like the content of the README file!
added content in hook_help()! needs review
Hey, I made some changes in hook_help()! needs review
Getting error while applying this patch #2
I made changes in the .module file and created a .help.yml file. need review!
dharmeshbarot â made their first commit to this issueâs fork.
I made the changes in 3339230-hookhelp-function-missing branch! needs review
dharmeshbarot â made their first commit to this issueâs fork.
The patch was applied successfully and moved to RTBC.
In the above patch #2, you just added one empty line and it doesn't work.
#2 patch applied successfully. above you can see a snapshot of the successful patch applied. moving to RTBC
I will review your patch.
Try to run update.php it may work!
Try this..