You are here

function linkchecker_entity_insert in Link checker 8

Implements hook_entity_insert().

File

./linkchecker.module, line 148
This module periodically check links in given node types, blocks etc.

Code

function linkchecker_entity_insert(EntityInterface $entity) {
  if ($entity instanceof LinkCheckerLinkInterface) {
    return;
  }
  if ($entity instanceof FieldableEntityInterface) {

    /** @var \Drupal\linkchecker\LinkExtractorService $extractor */
    $extractor = \Drupal::service('linkchecker.extractor');
    $links = $extractor
      ->extractFromEntity($entity);
    $extractor
      ->saveLinkMultiple($links);
    $extractor
      ->updateEntityExtractIndex($entity);
    \Drupal::service('linkchecker.clean_up')
      ->cleanUpForEntity($entity);
  }
}