/** * Retrieves HTML code of relating elements of initially related or * explicitly selected element. * * @param array $data custom data to be passed to template on rendering * @param string $template name of custom template to use instead of default one on rendering * @param int $listNodeAtIndex index of node to list properties of * (default: node at opposite end of relation) * @return string rendering result */ public function render($data = array(), $template = null, $listNodeAtIndex = -1) { $query = $this->query(); // extend query to fetch all properties of selected node's model $query->addProperty($this->datasource->qualifyDatasetName($this->nodeAtIndex($listNodeAtIndex)->getName()) . '.*'); // process query $matches = $query->execute()->all(); // start variable space initialized using provided set of custom data $data = variable_space::fromArray($data); // add fetched relation instances to variable space $data->update('matches', $matches); // add reference on current relation manager instance $data->update('relation', $this); // render variable space using selected or default template return view::render($template ? $template : 'model/relation/generic', $data); }