W3cubDocs

/Drupal 8

protected function ConfigBase::castSafeStrings

protected ConfigBase::castSafeStrings($data)

Casts any objects that implement MarkupInterface to string.

Parameters

mixed $data: The configuration data.

Return value

mixed The data with any safe strings cast to string.

File

core/lib/Drupal/Core/Config/ConfigBase.php, line 284

Class

ConfigBase
Provides a base class for configuration objects with get/set support.

Namespace

Drupal\Core\Config

Code

protected function castSafeStrings($data) {
  if ($data instanceof MarkupInterface) {
    $data = (string) $data;
  }
  elseif (is_array($data)) {
    array_walk_recursive($data, function(&$value) {
      if ($value instanceof MarkupInterface) {
        $value = (string) $value;
      }
    });
  }
  return $data;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigBase.php/function/ConfigBase::castSafeStrings/8.1.x