Problem/Motivation

There's 7 usages in CORE using same code to encode the Tags. We copy and paste it over and over again. It makes hard to maintain the code. And less possible to add custom encode rule to the Tags.

Proposed resolution

Add a shared method to \Drupal\Component\Utility\Tags class

Remaining tasks

- Review patch

User interface changes

- N / A

API changes

- added a new method in \Drupal\Component\Utility\Tags class

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu’s picture

This makes perfect sense.

+++ b/core/lib/Drupal/Component/Utility/Tags.php
@@ -43,6 +43,22 @@ public static function explode($tags) {
+   * @param array $tag
+   *   An string of tag.

The function receives a string, not an array :) And the text might be changed to "A tag string."

Status: Needs review » Needs work

The last submitted patch, tags-encode.patch, failed testing.

droplet’s picture

Status: Needs work » Needs review
FileSize
8.24 KB

Fixed the errors

Status: Needs review » Needs work

The last submitted patch, 3: tags-encode-3.patch, failed testing.

droplet’s picture

Status: Needs work » Needs review
FileSize
8.24 KB

remove extra end quote

Status: Needs review » Needs work

The last submitted patch, 5: tags-encode-5.patch, failed testing.

droplet’s picture

FileSize
8.22 KB

It should work this time.

droplet’s picture

Status: Needs work » Needs review
amateescu’s picture

Status: Needs review » Needs work

Please see #1. Also, the method description should be something like: Encodes a tag string, taking care of special cases like commas and quotes.

droplet’s picture

Status: Needs work » Needs review
FileSize
8.2 KB
517 bytes

Update the comments.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now.

catch’s picture

Title: Improve consistency of Tags encode » Change record: Improve consistency of Tags encode
Status: Reviewed & tested by the community » Active
Issue tags: +API addition, +Missing change record

Committed/pushed to 8.x, thanks!

Could use a change record for the API addition.

jessebeach’s picture

Status: Active » Fixed
Issue tags: -Missing change record

Change record added and reviewed. This was a simple API method addition.

jessebeach’s picture

Title: Change record: Improve consistency of Tags encode » Improve consistency of Tags encode

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.