Same filename and directory in other branches
- 8.9.x core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
- 9 core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
Namespace
Drupal\tour_test\Plugin\tour\tip
File
core/modules/tour/tests/tour_test/src/Plugin/tour/tip/TipPluginImage.php
View source
<?php
namespace Drupal\tour_test\Plugin\tour\tip;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Utility\Token;
use Drupal\tour\TipPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TipPluginImage extends TipPluginBase implements ContainerFactoryPluginInterface {
protected $url;
protected $alt;
protected $token;
public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->token = $token;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('token'));
}
public function getBody() : array {
$image = [
'#theme' => 'image',
'#uri' => $this
->get('url'),
'#alt' => $this
->get('alt'),
];
return [
'#type' => 'html_tag',
'#tag' => 'p',
'#attributes' => [
'class' => [
'tour-tip-image',
],
],
'image' => $image,
];
}
}
Classes