Commit 737f04d8 authored by alexpott's avatar alexpott

Issue #2030661 by lokeoke, lokapujya, larowlan, dinarcon, daffie, izus, Ivan...

Issue #2030661 by lokeoke, lokapujya, larowlan, dinarcon, daffie, izus, Ivan Zugec: Expand Tour with methods
parent 6ff433b6
......@@ -34,21 +34,21 @@ class Tour extends ConfigEntityBase implements TourInterface {
*
* @var string
*/
public $id;
protected $id;
/**
* The module which this tour is assigned to.
*
* @var string
*/
public $module;
protected $module;
/**
* The label of the tour.
*
* @var string
*/
public $label;
protected $label;
/**
* The routes on which this tour should be displayed.
......@@ -120,6 +120,13 @@ public function getTips() {
return array_values($tips);
}
/**
* {@inheritdoc}
*/
public function getModule() {
return $this->module;
}
/**
* {@inheritdoc}
*/
......
......@@ -104,7 +104,7 @@ public function getLocation() {
}
/**
* Overrides \Drupal\tour\TipPluginBase::getAttributes().
* {@inheritdoc}
*/
public function getAttributes() {
$attributes = parent::getAttributes();
......@@ -117,7 +117,7 @@ public function getAttributes() {
}
/**
* Implements \Drupal\tour\TipPluginInterface::getOutput().
* {@inheritdoc}
*/
public function getOutput() {
$output = '<h2 class="tour-tip-label" id="tour-tip-' . $this->getAriaId() . '-label">' . String::checkPlain($this->getLabel()) . '</h2>';
......
......@@ -42,28 +42,35 @@ abstract class TipPluginBase extends PluginBase implements TipPluginInterface {
protected $attributes;
/**
* Implements \Drupal\tour\TipPluginInterface::getLabel().
* {@inheritdoc}
*/
public function id() {
return $this->get('id');
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->get('label');
}
/**
* Implements \Drupal\tour\TipPluginInterface::getWeight().
* {@inheritdoc}
*/
public function getWeight() {
return $this->get('weight');
}
/**
* Implements \Drupal\tour\TipPluginInterface::getAttributes().
* {@inheritdoc}
*/
public function getAttributes() {
return $this->get('attributes');
}
/**
* Implements \Drupal\tour\TipPluginInterface::get().
* {@inheritdoc}
*/
public function get($key) {
if (!empty($this->configuration[$key])) {
......@@ -72,7 +79,7 @@ public function get($key) {
}
/**
* Implements \Drupal\tour\TipPluginInterface::set().
* {@inheritdoc}
*/
public function set($key, $value) {
$this->configuration[$key] = $value;
......
......@@ -17,6 +17,14 @@
*/
interface TipPluginInterface {
/**
* Returns id of the tip.
*
* @return string
* The id of the tip.
*/
public function id();
/**
* Returns label of the tip.
*
......
......@@ -54,6 +54,14 @@ public function getTip($id);
*/
public function getTips();
/**
* Gets the module this tour belongs to.
*
* @return string
* The module this tour belongs to.
*/
public function getModule();
/**
* Resets the statically cached keyed routes.
*/
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityViewBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\Html;
/**
* Provides a Tour view builder.
......@@ -29,9 +30,9 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
if ($output = $tip->getOutput()) {
$attributes = array(
'class' => array(
'tip-module-' . drupal_clean_css_identifier($entity->get('module')),
'tip-type-' . drupal_clean_css_identifier($tip->get('plugin')),
'tip-' . drupal_clean_css_identifier($tip->get('id')),
'tip-module-' . Html::cleanCssIdentifier($entity->getModule()),
'tip-type-' . Html::cleanCssIdentifier($tip->getPluginId()),
'tip-' . Html::cleanCssIdentifier($tip->id()),
),
);
$list_items[] = array(
......
......@@ -37,7 +37,7 @@ class TipPluginImage extends TipPluginBase {
protected $alt;
/**
* Overrides \Drupal\tour\Plugin\tour\tour\TipPluginInterface::getOutput().
* {@inheritdoc}
*/
public function getOutput() {
$image = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment