title: ZF2 - How to change the error/404 response page? Not just template but to set a new ViewModel
body: <p>By default the page is set like this in the <code>Application</code> module.config array:</p>
  
  <pre><code>'template_map' =&gt; array(
      'error/404' =&gt; __DIR__ . '/../view/error/404.phtml'
  </code></pre>
  
  <p>I want to change the page. I want new <code>ViewModel</code> for it full of variables. It means that simply to change the template is not enough:</p>
  
  <pre><code>'error/404' =&gt; __DIR__ . '/../view/error/my_new_404_template.phtml'
  </code></pre>
  
  <p>But I can't understand how to make it. I can't see the way the request comes to the <code>'error/404'</code>. </p>
  
  <ul>
  <li><p>How to create new <code>ViewModel</code> for it?</p></li>
  <li><p>How to attach variables to it?</p></li>
  <li><p>How the route comes to <code>'error/404'</code> to catch it to change?</p></li>
  </ul>
  
  <p>For example, I have such a method for <code>'error/404'</code> page:</p>
  
  <pre><code>public function pageNotFoundAction() {
  
      $view = new ViewModel();
  
      $view-&gt;setTemplate('error/404');     // set my template
  
      $sm = $this-&gt;getServiceLocator()-&gt;get('SessionManager');
      $cont = new Container('SomeNamespace', $sm);
  
      $view-&gt;var1 = $cont-&gt;offsetGet('someValue1');   // the "error/404" template
      $view-&gt;var2 = $cont-&gt;offsetGet('someValue2');   //       is full of variables
      $view-&gt;var3 = $cont-&gt;offsetGet('someValue3');
      $view-&gt;var4 = "One more view variable";
  
      // And now I return it somewhere and want it to be called
      //    in case of "the page is not found"
      return $view;
  }
  </code></pre>
  
  <p>How to make such a change? I can't get the system they've created to deal with things like <code>'error/404'</code>. Please help.</p>
  
  <p><strong>UPD 1</strong></p>
  
  <p>Even more complicated task. How to have several <code>'error/404'</code> pages?
  Would like to ask guys who created the framework whether they know that <code>'not_found_template'</code> cannot have an array of  <code>'error/404'</code> pages. How it can be? If I set this option like this:</p>
  
  <pre><code>'template_map' =&gt; array(
      'error/404' =&gt; __DIR__ . '/../view/error/404.phtml',
      'my-page/one_more_error404' =&gt; __DIR__ . '/../view/my-page/my-page/one_more_error404.phtml',
      'other_page/second_404' =&gt; __DIR__ . '/../view/other-page/one_more_error404.phtml',
  
  'not_found_template' =&gt; array(
      'error/404',
      'my-page/one_more_error404',
      'other-page/second_404',
  );
  </code></pre>
  
  <p>it throws an error. <code>'not_found_template'</code> force you to have only one <code>'error/404'</code> template?</p>