public function render()
{
$subject = $this->getArgumentFromArgumentsOrTagContent('subject');
$sorted = null;
if (true === is_array($subject)) {
$sorted = $this->sortArray($subject);
} else {
if (true === $subject instanceof ObjectStorage || true === $subject instanceof LazyObjectStorage) {
$sorted = $this->sortObjectStorage($subject);
} elseif (true === $subject instanceof \Iterator) {
/** @var \Iterator $subject */
$array = iterator_to_array($subject, true);
$sorted = $this->sortArray($array);
} elseif (true === $subject instanceof QueryResultInterface) {
/** @var QueryResultInterface $subject */
$sorted = $this->sortArray($subject->toArray());
} elseif (null !== $subject) {
// a NULL value is respected and ignored, but any
// unrecognized value other than this is considered a
// fatal error.
throw new \Exception('Unsortable variable type passed to Iterator/SortViewHelper. Expected any of Array, QueryResult, ' . ' ObjectStorage or Iterator implementation but got ' . gettype($subject), 1351958941);
}
}
return $this->renderChildrenWithVariableOrReturnInput($sorted);
}