Unverified Commit f9bb5b85 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3195193 by andregp, paulocs, andypost, quietone, catch: Remove Shepherd shim code from Tour

parent 189d5a84
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -42,23 +42,12 @@ tour.tip:
    weight:
      type: integer
      label: 'Weight'
    location:
      deprecated: "The tour.tip 'location' config schema property is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Instead use 'position'. The value must be a valid placement accepted by PopperJS. See https://www.drupal.org/node/3204093"
      type: string
      label: 'Location'
    position:
      type: string
      label: 'Position'
    selector:
      type: string
      label: 'Selector'
    attributes:
      deprecated: "The tour.tip 'attributes' config schema property is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Instead of 'data-class' and 'data-id' attributes, use 'selector' to specify the element a tip attaches to. See https://www.drupal.org/node/3204093"
      type: sequence
      label: 'Attributes'
      sequence:
        type: string
        label: 'Attribute'

tour.tip.text:
  type: tour.tip
+0 −10
Original line number Diff line number Diff line
@@ -70,14 +70,4 @@ public function getBody(): array {
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getOutput() {
    // Call parent to trigger error when calling this function.
    parent::getOutput();
    $output = '<p class="tour-tip-body">' . $this->token->replace($this->get('body')) . '</p>';
    return ['#markup' => $output];
  }

}
+0 −78
Original line number Diff line number Diff line
@@ -28,28 +28,6 @@ abstract class TipPluginBase extends PluginBase implements TipPluginInterface {
   */
  protected $weight;

  /**
   * The attributes that will be applied to the markup of this tip.
   *
   * @var array
   *
   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
   *   direct replacement. Note that this was never actually used.
   *
   * @see https://www.drupal.org/node/3204096
   */
  protected $attributes;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    if (!$this instanceof TourTipPluginInterface) {
      @trigger_error('Implementing ' . __NAMESPACE__ . '\TipPluginInterface without also implementing ' . __NAMESPACE__ . '\TourTipPluginInterface is deprecated in drupal:9.2.0. See https://www.drupal.org/node/3204096', E_USER_DEPRECATED);
    }
  }

  /**
   * {@inheritdoc}
   */
@@ -71,38 +49,6 @@ public function getWeight() {
    return $this->get('weight');
  }

  /**
   * {@inheritdoc}
   *
   * @todo remove in https://drupal.org/node/3195193
   */
  public function getAttributes() {
    // This method is deprecated and rewritten to be as backwards compatible as
    // possible with pre-existing uses. Due to the flexibility of tip plugins,
    // this backwards compatibility can't be fully guaranteed. Because of this,
    // we trigger a warning to caution the use of this function. This warning
    // does not stop page execution, but will be logged.
    trigger_error(__NAMESPACE__ . '\TipPluginInterface::getAttributes is deprecated. Tour tip plugins should implement ' . __NAMESPACE__ . '\TourTipPluginInterface and Tour configs should use the \'selector\' property instead of \'attributes\' to target an element.', E_USER_WARNING);

    // The _tour_update_joyride() updates the deprecated 'attributes' property
    // to the current 'selector' property. It's possible that additional
    // attributes not supported by Drupal core exist and these need to merged
    // in.
    $attributes = $this->get('attributes') ?: [];

    // Convert the selector property to the expected structure.
    $selector = $this->get('selector');
    $first_char = substr($selector, 0, 1);
    if ($first_char === '#') {
      $attributes['data-id'] = substr($selector, 1);
    }
    elseif ($first_char === '.') {
      $attributes['data-class'] = substr($selector, 1);
    }

    return $attributes;
  }

  /**
   * {@inheritdoc}
   */
@@ -119,30 +65,6 @@ public function set($key, $value) {
    $this->configuration[$key] = $value;
  }

  /**
   * This method should not be used. It is deprecated from TipPluginInterface.
   *
   * @return array
   *   An intentionally empty array.
   *
   * @todo remove in https://drupal.org/node/3195193
   */
  public function getOutput() {
    // The getOutput() method was a requirement of TipPluginInterface, but was
    // not part of TipPluginBase prior to it being deprecated. As a result, all
    // tip plugins have their own implementations of getOutput() making it
    // unlikely that this implementation will be called. If it does get called,
    // however, the tour tip will have no content due to this method returning
    // an empty array. To help tour tips from unexpectedly having no content, a
    // warning is triggered. This warning does not stop page
    // execution, but will be logged.
    trigger_error(__NAMESPACE__ . 'TipPluginInterface::getOutput is deprecated. Use getBody() instead. See https://www.drupal.org/node/3204096', E_USER_WARNING);

    // This class must implement TipPluginInterface, but this method is
    // deprecated. An empty array is returned to meet interface requirements.
    return [];
  }

  /**
   * Determines the placement of the tip relative to the element.
   *
+0 −25
Original line number Diff line number Diff line
@@ -36,18 +36,6 @@ public function getLabel();
   */
  public function getWeight();

  /**
   * Returns an array of attributes for the tip wrapper.
   *
   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. The
   *   attributes property is no longer used.
   * @see https://www.drupal.org/node/3204093
   *
   * @return array
   *   An array of classes and values.
   */
  public function getAttributes();

  /**
   * Used for returning values by key.
   *
@@ -70,17 +58,4 @@ public function get($key);
   */
  public function set($key, $value);

  /**
   * Returns a renderable array.
   *
   * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use
   *   getBody() instead, and do not include the tip label in the returned
   *   output.
   * @see https://www.drupal.org/node/3195234
   *
   * @return array
   *   A renderable array.
   */
  public function getOutput();

}
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
 * @see plugin_api
 *
 * @todo move all methods to TipPluginInterface and deprecate this interface in
 *   https://drupal.org/node/3195193
 *   https://drupal.org/i/3276336
 */
interface TourTipPluginInterface extends TipPluginInterface {

Loading