PHP code example of zemd / symfony-menu

1. Go to this page and download the library: Download zemd/symfony-menu 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/ */

    

zemd / symfony-menu example snippets


class MyController {
  
  /**
   * This route should be skipped from menu chain
   * 
   * @Breadcrumbs(skip=true)
   */
  public function myActionIwantToSkip() {}
  
  /**
   * This route should be in the root of menu tree 
   *
   * @Route("/dashboard", name="dashboard")
   * @Breadcrumbs(root=true)
   */
  public function dashboardAction() {}
  
  /**
   * This route should be added automatically into menu chain 
   *
   * @Route("/dashboard/graphs")
   */
  public function viewMoreGraphsAction() {}
}

class BreadcrumbsGlobalExtension extends \Twig_Extension implements Twig_Extension_GlobalsInterface
{
    const NAME = 'zemd_breadcrumbs_extension';

    /** @var BreadCrumbsManager */
    protected $breadcrumbsManager;

    public function __construct(BreadCrumbsManager $breadcrumbsManager) {
        $this->breadcrumbsManager = $breadcrumbsManager;
    }

    /**
     * Returns the name of the extension.
     *
     * @return string The extension name
     */
    public function getName() {
        return self::NAME;
    }

    public function getGlobals() {
        return [
            'zemd_breadcrumbs' => $this->breadcrumbsManager->getBreadcrumbs()
        ];
    }
}