castToString example


  protected static function castToString(array $normalization) {
    foreach ($normalization as $key => $value) {
      if (is_bool($value)) {
        $normalization[$key] = (string) (int) $value;
      }
      elseif (is_int($value) || is_float($value)) {
        $normalization[$key] = (string) $value;
      }
      elseif (is_array($value)) {
        $normalization[$key] = static::castToString($value);
      }
    }
    return $normalization;
  }

  /** * Tests a POST request for an entity, plus edge cases to ensure good DX. */
  public function testPost() {
    // @todo Remove this in https://www.drupal.org/node/2300677.     if ($this->entity instanceof ConfigEntityInterface) {
      

  protected function applyXmlConfigEntityDecodingQuirks(array $normalization) {
    $normalization = static::castToString($normalization);

    // When a single dependency is listed, it's not decoded into an array.     if (isset($normalization['dependencies'])) {
      foreach ($normalization['dependencies'] as $dependency_type => $dependency_list) {
        if (count($dependency_list) === 1) {
          $normalization['dependencies'][$dependency_type] = $dependency_list[0];
        }
      }
    }

    return $normalization;
  }
Home | Imprint | This part of the site doesn't use cookies.