public static function ProfileFormWidget::saveProfiles in Profile 8
Completes and saves all profiles.
Parameters
array $form: The complete form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- src/
Plugin/ Field/ FieldWidget/ ProfileFormWidget.php, line 301
Class
- ProfileFormWidget
- Plugin implementation of the 'profile_form' widget.
Namespace
Drupal\profile\Plugin\Field\FieldWidgetCode
public static function saveProfiles(array $form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Session\AccountInterface $account */
$account = $form_state
->getFormObject()
->getEntity();
if (!$account) {
return;
}
$profiles = $form_state
->get('profiles');
foreach ($profiles as $profile) {
assert($profile instanceof ProfileInterface);
$profile
->setOwnerId($account
->id());
$profile
->setPublished();
$profile
->save();
}
}