Prado\Web\UI\WebControls\TDataBoundControl::validateDataSource PHP Méthode

validateDataSource() protected méthode

If it is a string or an array, it will be converted as a TList object.
protected validateDataSource ( $value ) : Traversable
Résultat Traversable the data that is traversable
    protected function validateDataSource($value)
    {
        if (is_string($value)) {
            $list = new TList();
            foreach (TPropertyValue::ensureArray($value) as $key => $value) {
                if (is_array($value)) {
                    $list->add($value);
                } else {
                    $list->add(array($value, is_string($key) ? $key : $value));
                }
            }
            return $list;
        } else {
            if (is_array($value)) {
                return new TMap($value);
            } else {
                if ($value instanceof TDbDataReader) {
                    // read array from TDbDataReader since it's forward-only stream and can only be traversed once
                    return $value->readAll();
                } else {
                    if ($value instanceof \Traversable || $value === null) {
                        return $value;
                    } else {
                        throw new TInvalidDataTypeException('databoundcontrol_datasource_invalid', get_class($this));
                    }
                }
            }
        }
    }