diff --git a/src/Provider/PhoneNumberVerification.php b/src/Provider/PhoneNumberVerification.php index 1288cf2..34a475f 100644 --- a/src/Provider/PhoneNumberVerification.php +++ b/src/Provider/PhoneNumberVerification.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Utility\Token; use Drupal\sms\Direction; use Drupal\sms\Exception\PhoneNumberSettingsException; @@ -181,8 +182,8 @@ public function updatePhoneVerificationByEntity(EntityInterface $entity) { $phone_number_settings = $this->getPhoneNumberSettingsForEntity($entity); $field_name = $phone_number_settings->getFieldName('phone_number'); if (!empty($field_name)) { - $items_original = &$entity->original->{$field_name}; - $items = &$entity->{$field_name}; + $items_original = isset($entity->original) ? $entity->original->{$field_name} : NULL; + $items = $entity->{$field_name}; } } catch (PhoneNumberSettingsException $e) { @@ -196,7 +197,8 @@ public function updatePhoneVerificationByEntity(EntityInterface $entity) { } $numbers = []; - foreach ($items as &$item) { + assert($items instanceof FieldItemListInterface); + foreach ($items as $item) { $phone_number = $item->value; $numbers[] = $phone_number;