PHP code example of projektmotor / documentationbundle

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

    

projektmotor / documentationbundle example snippets


// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // activate bundle in AppKernel
        new Pm\DocumentationBundle\PmDocumentationBundle(),
        
        // if not yet done
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
    );
}

class MenuBuilder
{
    private $menuBuilderHelper;
    
    public function __construct(FactoryInterface $factory, MenuBuilderHelper $subMenuBuilder)
    {
        $this->factory = $factory;
        $this->menuBuilderHelper = $subMenuBuilder;
    }
}


class MenuBuilder
{
  // ....
  public function createMainMenu(RequestStack $requestStack)
  {
      $menu = $this->factory->createItem('root');

      // adding documentation menu as submenu
      $menu->addChild('Documentation', array(...));
      $this->subMenuBuilder->buildDocumentationMenu($menu['Documentation']);

      // OR adding as first-level menu
      $this->subMenuBuilder->buildDocumentationMenu($menu);
  }
  
  // ....
}