You are here

public function Toolbar::entityInsert in Simplifying 8

Entity insert actions.

File

src/Services/Toolbar.php, line 407

Class

Toolbar
Class Toolbar.

Namespace

Drupal\simplifying\Services

Code

public function entityInsert($entity) {
  $entity_type_id = $entity
    ->getEntityTypeId();
  if ($entity_type_id == 'webform_submission' || $entity_type_id == 'comment') {
    $entity_bundle = $entity
      ->bundle();
    $query = \Drupal::database()
      ->insert('simplifying_entity_unread');
    $query
      ->fields([
      'entity_type' => $entity_type_id,
      'bundle' => $entity_bundle,
      'entity_id' => $entity
        ->id(),
    ]);
    $query
      ->execute();
  }
}