<?php namespace Drupal\musin_core\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\musin_core\Service\UserHelperService; class CompletenessController extends ControllerBase { protected $entityTypeManager; public function populateCompleteness() { $query = \Drupal::entityQuery('user'); $uids = $query->execute(); foreach ($uids as $key => $id) { $user = \Drupal::entityTypeManager()->getStorage('user')->load($id); $result = UserHelperService::getProfileCompleteness($user); $user->set('field_completeness', $result); $user->save(); } return []; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter