I want to convert my legacy code to ZF2. But how?
Original Code:
$rows = $this->repository->getModelListing($model);
if (count($rows) == 0) {
?><h3>No products available</h3><?
return;
}
My Try:
if (count($rows) == 0)
{
$this->setPhpRenderer('Module');
$view = new ViewModel();
$view->setTemplate('no_products.phtml');
//(new View())->render($model);
echo $this->renderView($view);
return;
}
I found it a bit excessive. Can I not have a Template set and do something else? My concern is that from light-weight code I went to heavy-weigh ViewModel, and (new View())->render().