🇼🇳India @dharmeshbarot

Gujarat
Account created on 26 July 2022, over 2 years ago
#

Merge Requests

Recent comments

🇼🇳India dharmeshbarot Gujarat

Hello,

#34 works for drupal 9 also.

🇼🇳India dharmeshbarot Gujarat

Hello @rudrakumar188,

Can you specify what kind of error you face?

🇼🇳India dharmeshbarot Gujarat

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');
}

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

MR 2! is empty that's why it's generating an error, try to merge MR 1!

📌 | Country | Add a readme
🇼🇳India dharmeshbarot Gujarat
📌 | Country | Add a readme
🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

Following the merge request(41c9b644) solving the error. moving to RTBC

🇼🇳India dharmeshbarot Gujarat

Getting error while installing the module

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

Try this patch..! needs a review

🇼🇳India dharmeshbarot Gujarat

sorry for creating a fork for this issue!

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

created MR! for this issue and made changes that were told by @Anybody

🇼🇳India dharmeshbarot Gujarat

I think this patch will resolve all errors.

🇼🇳India dharmeshbarot Gujarat

Working on it!

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat
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();
  }
}

🇼🇳India dharmeshbarot Gujarat
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();
  }
}

🇼🇳India dharmeshbarot Gujarat

Try this if it's work.

🇼🇳India dharmeshbarot Gujarat
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();
  }
}

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

The MR! working fine! Moving to RTBC

🇼🇳India dharmeshbarot Gujarat

minor changes are implemented to the README.md file

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

There is no content in the README.txt file so we need to add content about how this module works.

🇼🇳India dharmeshbarot Gujarat

I made your changes in this branch also 3319902-replace-readme.txt-with

🇼🇳India dharmeshbarot Gujarat

Did you review my MR? @Manoj Raj.R

🇼🇳India dharmeshbarot Gujarat

Patch #1 was applied successfully and working fine! moving to RTBC

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

@saket-001, you have to enable(install) the module to see the help functionality.

🇼🇳India dharmeshbarot Gujarat

Created MR for the issue.
Please review.

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

I made changes in the Readme file as the name of the module in the .info file.

🇼🇳India dharmeshbarot Gujarat

made changes to the .module file and README file

🇼🇳India dharmeshbarot Gujarat

Patch #2 was applied successfully and working fine! moving to RTBC

🇼🇳India dharmeshbarot Gujarat

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

🇼🇳India dharmeshbarot Gujarat

And also we need to update the README.md file content in drupal standard

🇼🇳India dharmeshbarot Gujarat

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!

🇼🇳India dharmeshbarot Gujarat

added content in hook_help()! needs review

🇼🇳India dharmeshbarot Gujarat

Hey, I made some changes in hook_help()! needs review

🇼🇳India dharmeshbarot Gujarat

Getting error while applying this patch #2

🇼🇳India dharmeshbarot Gujarat

I made changes in the .module file and created a .help.yml file. need review!

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

I made the changes in 3339230-hookhelp-function-missing branch! needs review

🇼🇳India dharmeshbarot Gujarat

dharmeshbarot → made their first commit to this issue’s fork.

🇼🇳India dharmeshbarot Gujarat

The patch was applied successfully and moved to RTBC.

🇼🇳India dharmeshbarot Gujarat

In the above patch #2, you just added one empty line and it doesn't work.

🇼🇳India dharmeshbarot Gujarat

#2 patch applied successfully. above you can see a snapshot of the successful patch applied. moving to RTBC

🇼🇳India dharmeshbarot Gujarat

Try to run update.php it may work!

Production build 0.71.5 2024