TipPluginImage.php 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\tour_test\Plugin\tour\tour\TipPluginImage.
 */

namespace Drupal\tour_test\Plugin\tour\tip;

10
use Drupal\tour\Annotation\Tip;
11 12 13 14 15
use Drupal\tour\TipPluginBase;

/**
 * Displays an image as a tip.
 *
16
 * @Tip("image")
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 */
class TipPluginImage extends TipPluginBase {

  /**
   * The url which is used for the image in this Tip.
   *
   * @var string
   *   A url used for the image.
   */
  protected $url;

  /**
   * The alt text which is used for the image in this Tip.
   *
   * @var string
   *   A alt text used for the image.
   */
  protected $alt;

  /**
   * Overrides \Drupal\tour\Plugin\tour\tour\TipPluginInterface::getOutput().
   */
  public function getOutput() {
40 41 42 43 44
    $image = array(
      '#theme' => 'image',
      '#uri' => $this->get('url'),
      '#alt' => $this->get('alt'),
    );
45
    $output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->get('ariaId') . '-label">' . check_plain($this->get('label')) . '</h2>';
46
    $output .= '<p class="tour-tip-image" id="tour-tip-' . $this->get('ariaId') . '-contents">' . drupal_render($image) . '</p>';
47
    return array('#markup' => $output);
48
  }
49

50
}