You are here

public function InlineBlockUsage::addUsage in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/InlineBlockUsage.php \Drupal\layout_builder\InlineBlockUsage::addUsage()

Adds a usage record.

Parameters

int $block_content_id: The block content ID.

\Drupal\Core\Entity\EntityInterface $entity: The layout entity.

Overrides InlineBlockUsageInterface::addUsage

File

core/modules/layout_builder/src/InlineBlockUsage.php, line 33

Class

InlineBlockUsage
Service class to track inline block usage.

Namespace

Drupal\layout_builder

Code

public function addUsage($block_content_id, EntityInterface $entity) {
  $this->database
    ->merge('inline_block_usage')
    ->keys([
    'block_content_id' => $block_content_id,
    'layout_entity_id' => $entity
      ->id(),
    'layout_entity_type' => $entity
      ->getEntityTypeId(),
  ])
    ->execute();
}