title: Zend_Navigation: Getting Only the Pages Accessible by the Current User/Role
body: <p>I have a Zend_Navigation running with data provided by a navigation.xml file. Let's assume the first level (0) consists of two pages, Frontend and Backend. Frontend is accessible by the guest role, Backend only by the admin role.</p>
  
  <p>If I do a</p>
  
  <pre><code>&lt;?php echo $this-&gt;navigation()-&gt;menu()-&gt;setMaxDepth(0); ?&gt;
  </code></pre>
  
  <p>it correctly displays the "Frontend" link when not logged in, and both the "Frontend" and "Backend" links when logged in as an admin.</p>
  
  <p>However, displaying the "Frontend" link doesn't make much sense for guests, because they don't have any other pages to navigate to on that level anyway. So I would rather not display that navigation at all for guests.</p>
  
  <p>I know I could do</p>
  
  <pre><code>&lt;?php
  if ('guest' !== $this-&gt;view-&gt;role) {
      echo $this-&gt;navigation()-&gt;menu();
  }
  ?&gt;
  </code></pre>
  
  <p>but I'm hoping for a better way to do this.</p>
  
  <p>What I'm looking for is something like</p>
  
  <pre><code>&lt;?php
  if (count($this-&gt;navigation()-&gt;getPagesForRole($this-&gt;view-&gt;role)) &gt; 1) {
      echo $this-&gt;navigation()-&gt;menu();
  }
  ?&gt;
  </code></pre>
  
  <p>I can't figure out how to achieve this with the API provided by Zend_Navigation... I see there is a getPages() method, but it returns all pages "unfiltered".</p>
  
  <p>I assume there is an easy solution to this, but I've been trying to figure this out for the past two hours and found nothing, so I guess I'm looking in the wrong direction.</p>
  
  <p>Thanks for your time.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I forgot to mention that the navigation is already using ACL to control privileges, and it's working fine. My only problem is that I do not want to display the Frontend/Backend navigation for the guests, because a navigation of only one link item is pretty useless.
  Sorry about the confusion.</p>