public function visit(Visitor $visitor, Generator $generator, $data)
{
if ($data instanceof LocationQueryValue) {
$rootObjectElement = 'LocationQuery';
} else {
if ($data instanceof ContentQueryValue) {
$rootObjectElement = 'ContentQuery';
} else {
throw new Exceptions\InvalidArgumentException("ViewInput Query", "No content nor location query found in ViewInput");
}
}
$generator->startObjectElement($rootObjectElement, 'Query');
if (isset($data->filter)) {
$generator->startHashElement('Filter');
$visitor->visitValueObject($data->filter);
$generator->endHashElement('Filter');
}
if (isset($data->query)) {
$generator->startHashElement('Query');
$visitor->visitValueObject($data->query);
$generator->endhashElement('Query');
}
// $generator->startObjectElement('SortClauses');
// foreach ($data->sortClauses as $sortClause) {
// $visitor->visitValueObject($sortClause);
// }
// $generator->endObjectElement('SortClauses');
$generator->endObjectElement($rootObjectElement);
}