PHP code example of costsrl / cost-acl-navigation

1. Go to this page and download the library: Download costsrl/cost-acl-navigation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

costsrl / cost-acl-navigation example snippets

./config/application.config.php

'modules' => array(
    'Application',
    'CostAuthorization',
    'CostNavigation'
)

      $navHelper = $this->navigation('navigation_default');
      $containers = $navHelper->getContainer();
      $acl = $navHelper->getAcl();
      $role = $navHelper->getRole();
      foreach($containers->getPages() as $page) {    
              if(! $navHelper->accept($page))
                  continue;
                  $class = "";
                  if ($page->isActive() && $navHelper->accept($page)) {
                                    $class = "active";
                  }
    
                  if(count($page)) {
                       // if there are subpages we render the menu a bit different
                       $label  = $page->getLabel();
                       $label  = $this->translate($label); // translated label
                       $label  = $this->escapehtml($label); // sanitized label
                       printf('<li class="dropdown%s">'."\n",($class?' '.$class:''));
                       printf('<a href="%s" class="dropdown-toggle" data-toggle="dropdown">%s<b class="caret"></b></a>'."\n",
                                                 $page->getHref(),
                                                 $label);
                      echo '<ul class="dropdown-menu" role="menu">'."\n";
                      foreach($page as $subPage) {
                                   if(!$navHelper->accept($subPage)) {
                                           	continue;
                                   }
                                   printf("<li>%s</li>\n",$navHelper->htmlify($subPage));
                                                            }
                               echo "</ul></li>\n";
                 }
                  else {
                   printf("<li class=\"%s\">%s</li>\n",$class,$navHelper->htmlify($page));
             }
       }