UnsupportedDataTypeConfigException example

$filepath = $this->getFilePath($name);
    if ($data = $this->fileCache->get($filepath)) {
      return $data;
    }

    $data = file_get_contents($filepath);
    try {
      $data = $this->decode($data);
    }
    catch (InvalidDataTypeException $e) {
      throw new UnsupportedDataTypeConfigException('Invalid data type in config ' . $name . ', found in file ' . $filepath . ': ' . $e->getMessage());
    }
    $this->fileCache->set($filepath$data);

    return $data;
  }

  /** * {@inheritdoc} */
  public function readMultiple(array $names) {
    $list = [];
    

  protected function validateValue($key$value) {
    // Minimal validation. Should not try to serialize resources or non-arrays.     if (is_array($value)) {
      foreach ($value as $nested_value_key => $nested_value) {
        $this->validateValue($key . '.' . $nested_value_key$nested_value);
      }
    }
    elseif ($value !== NULL && !is_scalar($value)) {
      throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
    }
  }

  /** * Casts the value to correct data type using the configuration schema. * * @param string|null $key * A string that maps to a key within the configuration data. If NULL the * top level mapping will be processed. * @param mixed $value * Value to associate with the key. * * @return mixed * The value cast to the type indicated in the schema. * * @throws \Drupal\Core\Config\UnsupportedDataTypeConfigException * If the value is unsupported in configuration. */
Home | Imprint | This part of the site doesn't use cookies.