Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/parametertype/ConduitListParameterType.php
- This file was added.
<?php | |||||
abstract class ConduitListParameterType | |||||
extends ConduitParameterType { | |||||
protected function getParameterValue(array $request, $key) { | |||||
$value = parent::getParameterValue(); | |||||
if (!is_array($value)) { | |||||
$this->raiseValidationException( | |||||
$request, | |||||
$key, | |||||
pht('Expected a list, but value is not a list.')); | |||||
} | |||||
$actual_keys = array_keys($value); | |||||
if ($value) { | |||||
$natural_keys = range(0, count($value) - 1); | |||||
} else { | |||||
$natural_keys = array(); | |||||
} | |||||
if ($actual_keys !== $natural_keys) { | |||||
$this->raiseValidationException( | |||||
$request, | |||||
$key, | |||||
pht('Expected a list, but value is an object.')); | |||||
} | |||||
return $value; | |||||
} | |||||
protected function getParameterDefault() { | |||||
return array(); | |||||
} | |||||
} |