Problem Motivation

As the method token_replace() is removed from Drupal 8, let us remove all documentation references to it.
I did a directory search for the method and found 3 references to token_replace() in core file module.

/**
   * Determines the URI for a file field.
   *
   * @param array $data
   *   An array of token objects to pass to token_replace().
   *
   * @return string
   *   An unsanitized file directory URI with tokens replaced. The result of
   *   the token replacement is then converted to plain text and returned.
   *
   * @see token_replace()
   */
  public function getUploadLocation($data = array()) {
    return static::doGetUploadLocation($this->getSettings(), $data);
  }

**
   * Determines the URI for a file field.
   *
   * @param array $settings
   *   The array of field settings.
   * @param array $data
   *   An array of token objects to pass to token_replace().
   *
   * @return string
   *   An unsanitized file directory URI with tokens replaced. The result of
   *   the token replacement is then converted to plain text and returned.
   */
  protected static function doGetUploadLocation(array $settings, $data = []) {

Remaining tasks

Replace token_replace() with \Drupal::token()->replace();
Link to Token API drupal 8 core.

Comments

vishwac9 created an issue. See original summary.

ritzz’s picture

Assigned: Unassigned » ritzz

I am working on it.

ritzz’s picture

Version: 8.2.6 » 8.2.x-dev
Status: Active » Needs review
StatusFileSize
new1.36 KB
vishwac9’s picture

Status: Needs review » Reviewed & tested by the community

patch works well thanks @ritzz, changing the status to RTBC

shashikant_chauhan’s picture

Status: Reviewed & tested by the community » Needs work

@ritzz, small changes.

-   * @see token_replace()
+   * @see \Drupal::token()->replace();

1. Remove semicolon.

@@ -271,7 +271,7 @@ public function getUploadLocation($data = array()) {
    * @param array $settings
    *   The array of field settings.
    * @param array $data
-   *   An array of token objects to pass to token_replace().
+   *   An array of token objects to pass to \Drupal::token()->replace();

2. replace semicolon from "\Drupal::token()->replace();" to "."

ritzz’s picture

StatusFileSize
new1.36 KB
new1012 bytes
shashikant_chauhan’s picture

Status: Needs work » Needs review

updating status.

vickynandode’s picture

Status: Needs review » Reviewed & tested by the community

Everything looks good. Changing the status to RTBC

xjm’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Needs work

In documentation, we should reference the fully namespaced class and method for Token::replace(), rather than \Drupal and the service. Thanks!

ritzz’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB
new1.2 KB
jeetendrakumar’s picture

Status: Needs review » Reviewed & tested by the community

Look Good. Changing the status to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
    @@ -253,13 +253,13 @@ public static function validateMaxFilesize($element, FormStateInterface $form_st
    +   * @see Token::replace()
    

    This needs to be a fully qualified class name. I.e. @see \Drupal\Core\Utility\Token::replace().

  2. +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
    @@ -271,7 +271,7 @@ public function getUploadLocation($data = array()) {
    -   *   An array of token objects to pass to token_replace().
    +   *   An array of token objects to pass to Token::replace().
    

    Can we add an @see to this method too. So api.d.o links it up. The @see should be the same as the one above and below the @return.

Munavijayalakshmi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB
new1.02 KB
priyanka.attarde’s picture

Assigned: ritzz » Unassigned
Status: Needs review » Reviewed & tested by the community

thanks a lot @Munavijayalakshmi, patch applied good

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 0179304 to 8.4.x and 6b54e4c to 8.3.x. Thanks!

  • alexpott committed 0179304 on 8.4.x
    Issue #2857258 by ritzz, Munavijayalakshmi, shashikant_chauhan, xjm:...

  • alexpott committed 6b54e4c on 8.3.x
    Issue #2857258 by ritzz, Munavijayalakshmi, shashikant_chauhan, xjm:...
vishwac9’s picture

Status: Fixed » Closed (fixed)

Thanks a lot