-
-
Save vanloc0301/5427850 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Simpleshop\Modules\Admin\Presenters; | |
use Nette\Application\UI\Presenter; | |
use Simpleshop\Modules\Admin\Events\MenuEvent; | |
use Smf\Events\IEventDispatcher; | |
use Smf\Menu\Control\Factory; | |
abstract class BasePresenter extends Presenter | |
{ | |
const EVENT_MENU_CREATED = "simpleshop.admin.menuCreated"; | |
/** @var IEventDispatcher */ | |
protected $eventDispatcher; | |
/** @var Factory */ | |
protected $menuFactory; | |
public function injectEventDispatcher(IEventDispatcher $eventDispatcher) | |
{ | |
$this->eventDispatcher = $eventDispatcher; | |
} | |
public function injectMenuFactory(Factory $factory) | |
{ | |
$this->menuFactory = $factory; | |
} | |
protected function createComponentMenu() | |
{ | |
$menu = $this->menuFactory->createControl(); | |
$root = $menu->getRoot(); | |
$root->addChild('catalog', array( | |
'label' => 'Katalog', | |
'icon' => 'list', | |
)); | |
$this->eventDispatcher->dispatchEvent(self::EVENT_MENU_CREATED, new MenuEvent($menu)); | |
return $menu; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Simpleshop\Modules\Admin\Presenters; | |
/** | |
* Category presenter | |
*/ | |
use Doctrine\ODM\MongoDB\DocumentRepository; | |
use Knp\Menu\MenuItem; | |
use Nette\Application\BadRequestException; | |
use Simpleshop\Model\Documents\Category; | |
use Simpleshop\Modules\Admin\Events\MenuEvent; | |
use Smf\Events\Event; | |
class CategoryPresenter extends BasePresenter | |
{ | |
//... | |
/** | |
* @param \Simpleshop\Modules\Admin\Events\MenuEvent $event | |
* @eventListener(name=simpleshop.admin.menuCreated); | |
*/ | |
public static function onMenuCreate(MenuEvent $event) | |
{ | |
$menu = $event->getMenuControl(); | |
$catalog = $menu->root['catalog']; | |
$catalog->addChild('categories', array( | |
'label' => 'Kategorie', | |
'icon' => 'folder-open', | |
'link' => 'Category:list', | |
))->addChild('new', array( | |
'label' => 'Nová', | |
'icon' => 'plus', | |
'link' => 'Category:new', | |
)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by JetBrains PhpStorm. | |
* User: trunda | |
* Date: 05.02.13 | |
* Time: 15:20 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
namespace Simpleshop\Modules\Admin\Presenters; | |
use Simpleshop\Modules\Admin\Events\MenuEvent; | |
class ProductPresenter extends BasePresenter | |
{ | |
// ... | |
/** | |
* @param \Simpleshop\Modules\Admin\Events\MenuEvent $event | |
* @eventListener(name=simpleshop.admin.menuCreated); | |
*/ | |
public static function onMenuCreate(MenuEvent $event) | |
{ | |
$menu = $event->getMenuControl(); | |
$catalog = $menu->root['catalog']; | |
$catalog->addChild('products', array( | |
'label' => 'Produkty', | |
'icon' => 'cog', | |
'link' => 'Product:list', | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment