You can do it by writing your own view strategy.
First, register your new strategy in the configuration.
return array(
'factories' => array(
'MyStrategy' => 'Application\ViewRenderer\StrategyFactory',
)
'view_manager' => array(
'strategies' => array(
'MyStrategy'
),
),
);
Then, create your own strategy
namespace Application\ViewRenderer;
use Zend\View\Strategy\PhpRendererStrategy;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\FactoryInterface;
class StrategyFactory implements FactoryInterface
{
public function createService (ServiceLocatorInterface $serviceLocator)
{
$renderer = new Renderer ();
return new Strategy ($renderer);
}
}
and renderer.
namespace Application\ViewRenderer;
use Zend\View\Renderer\PhpRenderer;
class Renderer extends PhpRenderer
{
public function render($nameOrModel, $values = null) {
// this is just an example
// the actual implementation will be very much like in PhpRenderer
return 'x';
}
}