public static function EasyEmail::preCreate in Easy Email 8
Same name and namespace in other branches
- 2.0.x src/Entity/EasyEmail.php \Drupal\easy_email\Entity\EasyEmail::preCreate()
Changes the values of an entity before it is created.
Load defaults for example.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
mixed[] $values: An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.
Overrides EntityBase::preCreate
File
- src/
Entity/ EasyEmail.php, line 95
Class
- EasyEmail
- Defines the Email entity.
Namespace
Drupal\easy_email\EntityCode
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
/** @var \Drupal\easy_email\EasyEmailStorageInterface $storage_controller */
parent::preCreate($storage_controller, $values);
/** @var \Drupal\easy_email\Entity\EasyEmailTypeInterface $easy_email_type */
$easy_email_type = $storage_controller
->getEmailTypeStorage()
->load($values['type']);
$values += [
'creator_uid' => \Drupal::currentUser()
->id(),
'key' => $easy_email_type
->getKey(),
'from_name' => $easy_email_type
->getFromName(),
'from_address' => $easy_email_type
->getFromAddress(),
'reply_to' => $easy_email_type
->getReplyToAddress(),
'subject' => $easy_email_type
->getSubject(),
'body_html' => $easy_email_type
->getBodyHtml(),
'body_plain' => $easy_email_type
->getBodyPlain(),
'inbox_preview' => $easy_email_type
->getInboxPreview(),
'recipient_address' => $easy_email_type
->getRecipient(),
'cc_address' => $easy_email_type
->getCc(),
'bcc_address' => $easy_email_type
->getBcc(),
'attachment_path' => $easy_email_type
->getAttachment(),
];
}