2017 © Pedro Peláez
 

library menufactory

A tool to create cool menu with PHP

image

acid-solutions/menufactory

A tool to create cool menu with PHP

  • Thursday, May 28, 2015
  • by daniel-acid
  • Repository
  • 3 Watchers
  • 0 Stars
  • 1,512 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Create complex menu without stress., (*1)

How to install

Edit app/config/app.php Add, (*2)

// 'providers'
'AcidSolutions\MenuFactory\MenuFactoryServiceProvider',

And, (*3)

// 'aliases'
'MenuFactory' => 'AcidSolutions\MenuFactory\MenuFactoryFacade',

How to use

Call the factory, (*4)

$menu = MenuFactory::createMenu('MenuName');

Define one or more children, (*5)

$menu->add('Menu without Child');

Get html render for one menu, (*6)

$menu->renderHtml();
// OR
MenuFactory::render('MenuName');

Pattern

Pattern is a decoration for label, (*7)

$menu->add('Menu without Child but with pattern')->pattern('<strong>__LABEL__</strong>');
# OR
$pattern = '<strong>__LABEL__</strong>';
$menu->add('Menu without Child but with pattern1')->pattern($pattern);
$menu->add('Menu without Child but with pattern2')->pattern($pattern);
$menu->add('Menu without Child but with pattern3')->pattern($pattern);

Chained multilevel

Create multilevel menu by chaining add, (*8)

$menu->add('Menu with chained child')->add('First level')->add('Second level')->add('third level')->add('Fourth level');

Multiple child with closure

Create Multiple children with closure, you've access to all options, (*9)

$menu->add('Menu with multiple child defined by closure', function ($menu) {
  $menu->add('first child');
  $menu->add('second child');
  $menu->add('third child');
});

More menu? OK Let's DO ITTTT, (*10)

$menu->add('Menu with multiple child with multiple child defined by closure', function ($menu) {
  $menu->add('first child', function ($menu) {
    $menu->add('first child');
    $menu->add('second child');
    $menu->add('third child');
  });
  $menu->add('second child', function ($menu) {
    $menu->add('first child');
    $menu->add('second child');
    $menu->add('third child');
  });
  $menu->add('third child', function ($menu) {
    $menu->add('first child');
    $menu->add('second child');
    $menu->add('third child');
  });
});

Allow access with Closure

Sometime you need to hide or show menu item to group of user. Use closure to defined it!, (*11)

// Using Sentry::check() for this example (it will check if user is auth)
$userAuth = Sentry::check();
$menu->add('Menu with allow function')->allow(function () use ($userAuth) {
  // You can do everything you want here
  return $userAuth;
});

$menu->add('Menu with allow function (gonna be hide)')->allow(function () use ($userAuth) {
  // You can do everything you want here
  return !$userAuth;
});

// Wait, why closure if i've the value?
$menu->add('Menu with allow function (gonna be hide)')->allow($userAuth);

Option on item

To Apply option to an item (class, click, bisous), (*12)

$menu->add('Menu with Option')->option('class', 'btn');

Oh Shit i want to add btn class on the a, btn-group on the container li of the a and a dropdown-menu if this element have children...HOW!, (*13)

$menu->add('Menu with Option')
  ->option('class', 'btn')
  ->option('class', 'btn-group', 'li')
  ->option('class', 'dropdown-menu', 'ul');

Oh yes! links..., (*14)

$menu->add('Menu with uri')->uri('to_this_uri');

The Versions

28/05 2015

dev-master

9999999-dev

A tool to create cool menu with PHP

  Sources   Download

MIT

The Requires

 

by Daniel Lucas

28/05 2015

v0.0.2

0.0.2.0

A tool to create cool menu with PHP

  Sources   Download

MIT

The Requires

 

by Daniel Lucas

26/05 2015

v0.0.1

0.0.1.0

A tool to create cool menu with PHP

  Sources   Download

MIT

The Requires

 

by Daniel Lucas