You are here

protected static function TagViewBuilder::buildPreTag in Doubleclick for Publishers (DFP) 8

Builds a #pre_render-able DFP tag render array.

Parameters

\Drupal\dfp\View\TagView $tag_view: A DFP tag.

Return value

array A render array with a #pre_render callback to render the DFP tag.

See also

\Drupal\dfp\DfpResponseAttachmentsProcessor::processAttachments()

1 call to TagViewBuilder::buildPreTag()
TagViewBuilder::viewMultiple in src/View/TagViewBuilder.php
Builds the render array for the provided entities.

File

src/View/TagViewBuilder.php, line 159
Contains \Drupal\dfp\View\TagViewBuilder.

Class

TagViewBuilder
Provides a DFP Tag view builder.

Namespace

Drupal\dfp\View

Code

protected static function buildPreTag(TagView $tag_view) {
  $build = [
    '#contextual_links' => [
      'dfp_tag' => [
        'route_parameters' => [
          'dfp_tag' => $tag_view
            ->id(),
        ],
      ],
    ],
  ];
  if ($tag_view
    ->isShortTag()) {
    $build['tag'] = [
      '#theme' => 'dfp_short_tag',
      '#url_jump' => '//' . TagInterface::GOOGLE_SHORT_TAG_SERVICES_URL . '/jump?' . $tag_view
        ->getShortTagQueryString(),
      '#url_ad' => '//' . TagInterface::GOOGLE_SHORT_TAG_SERVICES_URL . '/ad?' . $tag_view
        ->getShortTagQueryString(),
    ];
  }
  else {
    $build['tag'] = [
      '#theme' => 'dfp_tag',
    ];

    // Attach a tag. These attachments are processed by
    // \Drupal\dfp\DfpResponseAttachmentsProcessor::processAttachments().
    $build['#attached']['dfp_slot'][] = $tag_view;
  }
  $build['tag']['#tag'] = $tag_view;
  return $build;
}