summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/layout_builder/src/InlineBlockUsageInterface.php
blob: 766964bcc9fd105ad311aa4c646af6b8d8bd0ce1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

namespace Drupal\layout_builder;

use Drupal\Core\Entity\EntityInterface;

/**
 * Defines an interface for tracking inline block usage.
 */
interface InlineBlockUsageInterface {

  /**
   * Adds a usage record.
   *
   * @param int $block_content_id
   *   The block content ID.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The layout entity.
   */
  public function addUsage($block_content_id, EntityInterface $entity);

  /**
   * Gets unused inline block IDs.
   *
   * @param int $limit
   *   The maximum number of block content entity IDs to return.
   *
   * @return int[]
   *   The entity IDs.
   */
  public function getUnused($limit = 100);

  /**
   * Remove usage record by layout entity.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The layout entity.
   */
  public function removeByLayoutEntity(EntityInterface $entity);

  /**
   * Delete the inline blocks' the usage records.
   *
   * @param int[] $block_content_ids
   *   The block content entity IDs.
   */
  public function deleteUsage(array $block_content_ids);

  /**
   * Gets usage record for inline block by ID.
   *
   * @param int $block_content_id
   *   The block content entity ID.
   *
   * @return object|false
   *   The usage record with properties layout_entity_id and layout_entity_type
   *   or FALSE if there is no usage.
   */
  public function getUsage($block_content_id);

}