public static function Comment::preCreate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::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 Entity::preCreate
File
- core/
modules/ comment/ src/ Entity/ Comment.php, line 534 - Contains \Drupal\comment\Entity\Comment.
Class
- Comment
- Defines the comment entity class.
Namespace
Drupal\comment\EntityCode
public static function preCreate(EntityStorageInterface $storage, array &$values) {
if (empty($values['comment_type']) && !empty($values['field_name']) && !empty($values['entity_type'])) {
$field_storage = FieldStorageConfig::loadByName($values['entity_type'], $values['field_name']);
$values['comment_type'] = $field_storage
->getSetting('comment_type');
}
}