protected function CustomerProfile::getProfileForOption in Commerce Core 8.2
Gets the address book profile for the given option ID.
Parameters
string $option_id: The option ID. A profile ID, or a special value ('_original', '_new').
Return value
\Drupal\profile\Entity\ProfileInterface|null The profile, or NULL if none found.
1 call to CustomerProfile::getProfileForOption()
- CustomerProfile::buildInlineForm in modules/
order/ src/ Plugin/ Commerce/ InlineForm/ CustomerProfile.php - Builds the inline form.
File
- modules/
order/ src/ Plugin/ Commerce/ InlineForm/ CustomerProfile.php, line 546
Class
- CustomerProfile
- Provides an inline form for managing a customer profile.
Namespace
Drupal\commerce_order\Plugin\Commerce\InlineFormCode
protected function getProfileForOption($option_id) {
$profile_storage = $this->entityTypeManager
->getStorage('profile');
/** @var \Drupal\profile\Entity\ProfileInterface $address_book_profile */
if ($option_id == '_new') {
$address_book_profile = $profile_storage
->create([
'type' => $this->entity
->bundle(),
'uid' => 0,
]);
}
elseif ($option_id == '_original') {
// The inline form is built with the original $this->entity,
// there is no need to update it in this case.
$address_book_profile = NULL;
}
else {
assert(is_numeric($option_id));
$address_book_profile = $profile_storage
->load($option_id);
}
return $address_book_profile;
}