public function AddressEventsSubscriber::onInitialValues in Commerce Demo 8
Alters the initial values.
Parameters
\Drupal\address\Event\InitialValuesEvent $event: The initial values event.
File
- src/
EventSubscriber/ AddressEventsSubscriber.php, line 25
Class
Namespace
Drupal\commerce_demo\EventSubscriberCode
public function onInitialValues(InitialValuesEvent $event) {
if ($event
->getFieldDefinition()
->getTargetEntityTypeId() == 'profile' && $event
->getFieldDefinition()
->getTargetBundle() == 'customer') {
$new_values = $this
->getRandomAddress() + $event
->getInitialValues();
$event
->setInitialValues($new_values);
}
}