-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
39 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
@@ -103,15 +101,16 @@ class Item implements ItemInterface | |
/** | ||
* Item constructor. | ||
* | ||
* @param string $name | ||
* @param string $id | ||
* @param $event | ||
*/ | ||
public function __construct(string $id, $event) | ||
{ | ||
$this->id = $id; | ||
$this->event = $event; | ||
} | ||
|
||
public function isEvent() | ||
public function isEvent(): bool | ||
{ | ||
return $this->event; | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
@@ -25,7 +23,7 @@ interface ItemInterface extends \ArrayAccess | |
* | ||
* @return bool | ||
*/ | ||
public function isEvent(); | ||
public function isEvent(): bool; | ||
|
||
/** | ||
* Get Item Array ID | Order ID. | ||
|
@@ -60,14 +58,14 @@ public function getLabel(): string; | |
public function setLabel(string $label); | ||
|
||
/** | ||
* Get Label After HTML | ||
* Get Label After HTML. | ||
* | ||
* @return string | ||
*/ | ||
public function getLabelAfterHtml(): string; | ||
|
||
/** | ||
* Label After Append HTML | ||
* Label After Append HTML. | ||
* | ||
* @param string $html | ||
* | ||
|
@@ -92,14 +90,14 @@ public function getLink(): string; | |
public function setLink(string $link); | ||
|
||
/** | ||
* Get Link After HTML | ||
* Get Link After HTML. | ||
* | ||
* @return string | ||
*/ | ||
public function getLinkAfterHtml(): string; | ||
|
||
/** | ||
* Label Link Append HTML | ||
* Label Link Append HTML. | ||
* | ||
* @param string $html | ||
* | ||
|
@@ -134,7 +132,7 @@ public function getRoute(): array; | |
* Change Menu Route. | ||
* | ||
* @param string $route | ||
* @param array $params | ||
* @param array $params | ||
* | ||
* @return ItemInterface | ||
*/ | ||
|
@@ -208,11 +206,11 @@ public function setLabelAttr(array $labelAttr); | |
* Get Extra Data Menu Item. | ||
* | ||
* @param string $name | ||
* @param null $default | ||
* @param false $default | ||
* | ||
* @return mixed | ||
*/ | ||
public function getExtra(string $name, $default = null); | ||
public function getExtra(string $name, $default = false); | ||
|
||
/** | ||
* Set Extra Data Menu Item. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,17 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
namespace Pd\MenuBundle\Builder; | ||
|
||
use Pd\MenuBundle\Event\PdMenuEvent; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | ||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; | ||
|
||
/** | ||
* Menu Item Processor. | ||
|
@@ -48,8 +46,9 @@ class ItemProcess implements ItemProcessInterface | |
/** | ||
* ItemProcess constructor. | ||
* | ||
* @param RouterInterface $router | ||
* @param RouterInterface $router | ||
* @param AuthorizationCheckerInterface $security | ||
* @param EventDispatcherInterface $eventDispatcher | ||
*/ | ||
public function __construct(RouterInterface $router, AuthorizationCheckerInterface $security, EventDispatcherInterface $eventDispatcher) | ||
{ | ||
|
@@ -62,15 +61,15 @@ public function __construct(RouterInterface $router, AuthorizationCheckerInterfa | |
* Menu Processor. | ||
* | ||
* @param ItemInterface $menu | ||
* @param array $options | ||
* @param array $options | ||
* | ||
* @return ItemInterface | ||
*/ | ||
public function processMenu(ItemInterface $menu, array $options = []): ItemInterface | ||
{ | ||
// Dispatch Event | ||
if ($menu->isEvent()) { | ||
$this->eventDispatcher->dispatch($menu->getId() . '.event', new PdMenuEvent($menu)); | ||
$this->eventDispatcher->dispatch(new PdMenuEvent($menu), $menu->getId().'.event'); | ||
} | ||
|
||
// Set Current URI | ||
|
@@ -84,6 +83,11 @@ public function processMenu(ItemInterface $menu, array $options = []): ItemInter | |
|
||
/** | ||
* Process Menu Item. | ||
* | ||
* @param ItemInterface $menu | ||
* @param $options | ||
* | ||
* @return bool | ||
*/ | ||
private function recursiveProcess(ItemInterface $menu, $options) | ||
{ | ||
|
@@ -109,7 +113,7 @@ private function recursiveProcess(ItemInterface $menu, $options) | |
} | ||
|
||
// Set Child List Class | ||
$child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()])); | ||
$child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_'.$child->getLevel()])); | ||
|
||
$childActive = $this->recursiveProcess($child, $options); | ||
} | ||
|
@@ -134,12 +138,13 @@ private function recursiveProcess(ItemInterface $menu, $options) | |
} | ||
|
||
// Sort Item | ||
usort($childs, function ($a, $b) { | ||
usort($childs, static function ($a, $b) { | ||
return $a->getOrder() > $b->getOrder(); | ||
}); | ||
|
||
// Set Childs | ||
$menu->setChild($childs); | ||
|
||
return $listActive; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
@@ -36,6 +34,7 @@ public function createMenu(array $options = []): ItemInterface | |
* Create Menu Item. | ||
* | ||
* @param string $name | ||
* @param bool $event | ||
* | ||
* @return ItemInterface | ||
*/ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,15 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
namespace Pd\MenuBundle\Event; | ||
|
||
use Pd\MenuBundle\Builder\ItemInterface; | ||
use Symfony\Component\EventDispatcher\Event; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
/** | ||
* Menu Event. | ||
|
@@ -43,7 +41,7 @@ public function __construct(ItemInterface $menu) | |
* | ||
* @return ItemInterface | ||
*/ | ||
public function getMenu() | ||
public function getMenu(): ItemInterface | ||
{ | ||
return $this->menu; | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
@@ -24,14 +22,14 @@ | |
class TwigRender implements RenderInterface | ||
{ | ||
/** | ||
* @var Twig_Environment | ||
* @var Environment | ||
*/ | ||
private $engine; | ||
|
||
/** | ||
* TwigRender constructor. | ||
* | ||
* @param Twig_Environment $engine | ||
* @param Environment $engine | ||
*/ | ||
public function __construct(Environment $engine) | ||
{ | ||
|
@@ -41,6 +39,9 @@ public function __construct(Environment $engine) | |
/** | ||
* Render Menu. | ||
* | ||
* @param ItemInterface $item | ||
* @param array $options | ||
* | ||
* @return string | ||
*/ | ||
public function render(ItemInterface $item, array $options = []): string | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,8 @@ | |
* This file is part of the pd-admin pd-menu package. | ||
* | ||
* @package pd-menu | ||
* | ||
* @license LICENSE | ||
* @author Kerem APAYDIN <[email protected]> | ||
* | ||
* @link https://github.com/appaydin/pd-menu | ||
*/ | ||
|
||
|
@@ -18,7 +16,7 @@ | |
use Pd\MenuBundle\Builder\MenuInterface; | ||
use Pd\MenuBundle\Render\RenderInterface; | ||
use Psr\Container\ContainerInterface; | ||
use Symfony\Component\Translation\TranslatorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
|
@@ -59,7 +57,7 @@ class MenuExtension extends AbstractExtension | |
'depth' => null, | ||
'currentClass' => 'active', | ||
'trans_domain' => null, | ||
'iconTemplate' => '<i class="material-icons">itext</i>' | ||
'iconTemplate' => '<i class="material-icons">itext</i>', | ||
]; | ||
|
||
/** | ||
|
@@ -68,6 +66,7 @@ class MenuExtension extends AbstractExtension | |
* @param RenderInterface $engine | ||
* @param ItemProcessInterface $itemProcess | ||
* @param ContainerInterface $container | ||
* @param TranslatorInterface $translator | ||
*/ | ||
public function __construct(RenderInterface $engine, ItemProcessInterface $itemProcess, ContainerInterface $container, TranslatorInterface $translator) | ||
{ | ||
|
@@ -126,7 +125,7 @@ public function renderMenu(string $menuClass = '', $options = []): string | |
* | ||
* @return ItemInterface|bool | ||
*/ | ||
public function getMenu(string $menuClass, $options = []): ItemInterface | ||
public function getMenu(string $menuClass, $options = []) | ||
{ | ||
// Merge Options | ||
$options = array_merge($this->defaultOptions, $options); | ||
|
@@ -147,10 +146,11 @@ public function getMenu(string $menuClass, $options = []): ItemInterface | |
* | ||
* @param array $array | ||
* @param array $append | ||
* @param array $options | ||
* | ||
* @return string | ||
*/ | ||
public function arrayToAttr(array $array = [], array $append = [], array $options = []) | ||
public function arrayToAttr(array $array = [], array $append = [], array $options = []): string | ||
{ | ||
$array = array_merge_recursive($array, $append); | ||
$attr = ''; | ||
|