PHP code example of zerkalica / millwright-menu-bundle

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

    

zerkalica / millwright-menu-bundle example snippets

 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Millwright\MenuBundle\MillwrightMenuBundle(),
        new Millwright\ConfigurationBundle\MillwrightConfigurationBundle(),
    );
    // ...
)
xml
        <service id="millwright_menu.options" class="%millwright_configuration.options.class%">
            <tag name="millwright_menu.menu_options" order="100"/>
            <argument type="collection">
                <argument key="items">%millwright_menu.items%</argument>
                <argument key="tree">%millwright_menu.tree%</argument>
                <argument key="renderers">%millwright_menu.renderers%</argument>
            </argument>
        </service>
 php
# src/Application/Millwright/CoreBundle/Controller/DefaultController.php
...
/**
 * @Menu(translateDomain="MillwrightMenuBundle")
 */
class DefaultController extends Controller {
    /**
     * @Route("/user/{user}", name="showUser")
     * @Template()
     * @Secure(roles="ROLE_ADMIN")
     * @SecureParam(name="user", permissions="EDIT")
     * @Menu(showNonAuthorized=true, label="User edit")
     */
    public function userAction(User $user) {
        return array('content' => 'hello');
    }
}
 php
# src/Application/Millwright/CoreBundle/Controller/ArticleController.php
...
/**
 * @Menu(translateDomain="MillwrightMenuBundle")
 */
class ArticleController extends Controller
{
    /**
     * @Route("/articles", name="article_index")
     * @Template()
     * @Secure(roles="ROLE_USER")
     */
    public function indexAction() {
        //
    }

    /**
     * @Route("/article/create", name="article_create")
     * @Template()
     * @Secure(roles="ROLE_USER")
     * @SecureParam(name="article", permissions="EDIT")
     */
    public function createAction() {
        //
    }

    /**
     * @Route("/article/{article}", name="article_view")
     * @Secure(roles="ROLE_USER")
     * @SecureParam(name="article", permissions="VIEW")
     * @Template()
     */
    public function viewAction(Article $article) {
        return array('article' => $article);
    }

    /**
     * @Route("/article/{article}/edit", name="article_edit")
     * @Template()
     * @Secure(roles="ROLE_USER")
     * @SecureParam(name="article", permissions="EDIT")
     */
    public function editAction(Article $article) {
        //
    }

    /**
     * @Route("/article/{article}/delete", name="article_delete")
     * @Template()
     * @Secure(roles="ROLE_USER")
     * @SecureParam(name="article", permissions="DELETE")
     */
    public function deleteAction(Article $article) {
        //
    }
}