Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SlotSourceProxy
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 2
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLabelWithSummary
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder;
6
7use Drupal\Component\Plugin\PluginManagerInterface;
8use Drupal\Component\Utility\Html;
9
10/**
11 * Provide methods missing in UI Patterns.
12 */
13class SlotSourceProxy {
14
15  public function __construct(
16    protected PluginManagerInterface $sourceManager,
17  ) {}
18
19  /**
20   * Get the label from data, with summary.
21   *
22   * @param array $data
23   *   The data to processed.
24   * @param \Drupal\Core\Plugin\Context\ContextInterface[] $contexts
25   *   (Optional) The contexts, keyed by context name.
26   *
27   * @return array{label: string, summary: string}
28   *   Array with keys 'label' and 'summary'.
29   */
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
36      return [
37        'label' => '',
38        'summary' => '',
39      ];
40    }
41    $label = (string) $source->label(TRUE);
42
43    $summary = $source->settingsSummary();
44    $labelSummary = $label;
45
46    if (\is_array($summary)) {
47      $summary = \array_map(static fn ($v) => \trim((string) $v), $summary);
48
49      if (!empty(\array_filter(\array_values($summary)))) {
50        $labelSummary .= ': ' . \implode(', ', $summary);
51      }
52    }
53    elseif (\is_string($summary)) {
54      $labelSummary .= ': ' . \trim($summary);
55    }
56
57    return [
58      'label' => $label,
59      // Block token can contain markup.
60      'summary' => Html::escape($labelSummary),
61    ];
62  }
63
64}

Paths

Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once. Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

SlotSourceProxy->__construct
15  public function __construct(
16    protected PluginManagerInterface $sourceManager,
17  ) {}
SlotSourceProxy->getLabelWithSummary
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
 
37        'label' => '',
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
 
41    $label = (string) $source->label(TRUE);
42
43    $summary = $source->settingsSummary();
44    $labelSummary = $label;
45
46    if (\is_array($summary)) {
 
47      $summary = \array_map(static fn ($v) => \trim((string) $v), $summary);
48
49      if (!empty(\array_filter(\array_values($summary)))) {
 
46    if (\is_array($summary)) {
47      $summary = \array_map(static fn ($v) => \trim((string) $v), $summary);
48
49      if (!empty(\array_filter(\array_values($summary)))) {
50        $labelSummary .= ': ' . \implode(', ', $summary);
 
58      'label' => $label,
59      // Block token can contain markup.
60      'summary' => Html::escape($labelSummary),
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
 
41    $label = (string) $source->label(TRUE);
42
43    $summary = $source->settingsSummary();
44    $labelSummary = $label;
45
46    if (\is_array($summary)) {
 
47      $summary = \array_map(static fn ($v) => \trim((string) $v), $summary);
48
49      if (!empty(\array_filter(\array_values($summary)))) {
 
58      'label' => $label,
59      // Block token can contain markup.
60      'summary' => Html::escape($labelSummary),
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
 
41    $label = (string) $source->label(TRUE);
42
43    $summary = $source->settingsSummary();
44    $labelSummary = $label;
45
46    if (\is_array($summary)) {
 
53    elseif (\is_string($summary)) {
 
54      $labelSummary .= ': ' . \trim($summary);
55    }
56
57    return [
58      'label' => $label,
 
58      'label' => $label,
59      // Block token can contain markup.
60      'summary' => Html::escape($labelSummary),
30  public function getLabelWithSummary(array $data, array $contexts = []): array {
31    /** @var \Drupal\ui_patterns\SourcePluginManager $sourceManager */
32    $sourceManager = $this->sourceManager;
33    $source = $sourceManager->getSource($data['node_id'] ?? '', [], $data, $contexts);
34
35    if (!$source) {
 
41    $label = (string) $source->label(TRUE);
42
43    $summary = $source->settingsSummary();
44    $labelSummary = $label;
45
46    if (\is_array($summary)) {
 
53    elseif (\is_string($summary)) {
 
58      'label' => $label,
59      // Block token can contain markup.
60      'summary' => Html::escape($labelSummary),
{closure:/var/www/html/web/modules/custom/display_builder/src/SlotSourceProxy.php:47-47}
47      $summary = \array_map(static fn ($v) => \trim((string) $v), $summary);