summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAlex Pott2013-06-19 10:47:53 (GMT)
committerAlex Pott2013-06-19 20:21:34 (GMT)
commitbe586a9954111ba51b0ce8de1844749b96a50e3a (patch)
tree37f9f3f65b0c759dbbd05c14abbdff7bf56718ee /core
parent2c61612951a24edaf4dfbd38791de0ea887dbfec (diff)
Issue #2019469 followup by larowlan: Tour module should use token for it's body.
Diffstat (limited to 'core')
-rw-r--r--core/modules/tour/lib/Drupal/tour/Plugin/tour/tip/TipPluginText.php38
-rw-r--r--core/modules/tour/lib/Drupal/tour/Tests/TourTest.php5
-rw-r--r--core/modules/tour/lib/Drupal/tour/TipPluginManager.php6
-rw-r--r--core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml2
4 files changed, 43 insertions, 8 deletions
diff --git a/core/modules/tour/lib/Drupal/tour/Plugin/tour/tip/TipPluginText.php b/core/modules/tour/lib/Drupal/tour/Plugin/tour/tip/TipPluginText.php
index cb93887..9484812 100644
--- a/core/modules/tour/lib/Drupal/tour/Plugin/tour/tip/TipPluginText.php
+++ b/core/modules/tour/lib/Drupal/tour/Plugin/tour/tip/TipPluginText.php
@@ -7,15 +7,18 @@
namespace Drupal\tour\Plugin\tour\tip;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Utility\Token;
use Drupal\tour\Annotation\Tip;
use Drupal\tour\TipPluginBase;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Displays some text as a tip.
*
* @Tip("text")
*/
-class TipPluginText extends TipPluginBase {
+class TipPluginText extends TipPluginBase implements ContainerFactoryPluginInterface {
/**
* The body text which is used for render of this Text Tip.
@@ -25,6 +28,13 @@ class TipPluginText extends TipPluginBase {
protected $body;
/**
+ * Token service.
+ *
+ * @var \Drupal\Core\Utility\Token
+ */
+ protected $token;
+
+ /**
* The forced position of where the tip will be located.
*
* @var string
@@ -32,6 +42,30 @@ class TipPluginText extends TipPluginBase {
protected $location;
/**
+ * Constructs a \Drupal\tour\Plugin\tour\tip\TipPluginText object.
+ *
+ * @param array $configuration
+ * A configuration array containing information about the plugin instance.
+ * @param string $plugin_id
+ * The plugin_id for the plugin instance.
+ * @param array $plugin_definition
+ * The plugin implementation definition.
+ * @param \Drupal\Core\Utility\Token $token
+ * The token service.
+ */
+ public function __construct(array $configuration, $plugin_id, array $plugin_definition, Token $token) {
+ parent::__construct($configuration, $plugin_id, $plugin_definition);
+ $this->token = $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) {
+ return new static($configuration, $plugin_id, $plugin_definition, $container->get('token'));
+ }
+
+ /**
* Returns a ID that is guaranteed uniqueness.
*
* @return string
@@ -83,7 +117,7 @@ class TipPluginText extends TipPluginBase {
*/
public function getOutput() {
$output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->getAriaId() . '-label">' . check_plain($this->getLabel()) . '</h2>';
- $output .= '<p class="tour-tip-body" id="tour-tip-' . $this->getAriaId() . '-contents">' . \Drupal::token()->replace(filter_xss_admin($this->getBody())) . '</p>';
+ $output .= '<p class="tour-tip-body" id="tour-tip-' . $this->getAriaId() . '-contents">' . filter_xss_admin($this->token->replace($this->getBody())) . '</p>';
return array('#markup' => $output);
}
}
diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
index a8e7b8a..db69e18 100644
--- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
+++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php
@@ -49,10 +49,11 @@ class TourTest extends WebTestBase {
));
$this->assertEqual(count($elements), 1, 'Found English variant of tip 1.');
- $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p[contains(., :text)]]', array(
+ $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array(
':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 even last',
':data_id' => 'tour-test-1',
- ':text' => 'Is Drupal always the best dressed?',
+ ':href' => url('<front>', array('absolute' => TRUE)),
+ ':text' => 'Drupal',
));
$this->assertEqual(count($elements), 1, 'Found Token replacement.');
diff --git a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php
index 4fc8b99..e23669b 100644
--- a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php
+++ b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php
@@ -7,12 +7,12 @@
namespace Drupal\tour;
+use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Component\Plugin\PluginManagerBase;
-use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
-use Drupal\Component\Plugin\Discovery\ProcessDecorator;
+use Drupal\Core\Plugin\Factory\ContainerFactory;
/**
* Configurable tour manager.
@@ -32,7 +32,7 @@ class TipPluginManager extends PluginManagerBase {
$this->discovery = new AlterDecorator($this->discovery, 'tour_tips_info');
$this->discovery = new CacheDecorator($this->discovery, 'tour');
- $this->factory = new DefaultFactory($this->discovery);
+ $this->factory = new ContainerFactory($this->discovery);
}
}
diff --git a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml
index 31dd411..9d389ed 100644
--- a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml
+++ b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml
@@ -9,7 +9,7 @@ tips:
id: tour-test-1
plugin: text
label: The first tip
- body: Is [site:name] always the best dressed?
+ body: Is <a href="[site:url]">[site:name]</a> always the best dressed?
weight: "1"
attributes:
data-id: tour-test-1