Skip to content

Commit

Permalink
Symfony 4.3 Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cesurapp committed Jun 24, 2019
1 parent 37c9889 commit 742a2a2
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 49 deletions.
7 changes: 3 additions & 4 deletions Builder/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 8 additions & 10 deletions Builder/ItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -25,7 +23,7 @@ interface ItemInterface extends \ArrayAccess
*
* @return bool
*/
public function isEvent();
public function isEvent(): bool;

/**
* Get Item Array ID | Order ID.
Expand Down Expand Up @@ -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
*
Expand All @@ -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
*
Expand Down Expand Up @@ -134,7 +132,7 @@ public function getRoute(): array;
* Change Menu Route.
*
* @param string $route
* @param array $params
* @param array $params
*
* @return ItemInterface
*/
Expand Down Expand Up @@ -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.
Expand Down
23 changes: 14 additions & 9 deletions Builder/ItemProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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);
}
Expand All @@ -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;
}
}
}
2 changes: 0 additions & 2 deletions Builder/ItemProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
3 changes: 1 addition & 2 deletions Builder/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down Expand Up @@ -36,6 +34,7 @@ public function createMenu(array $options = []): ItemInterface
* Create Menu Item.
*
* @param string $name
* @param bool $event
*
* @return ItemInterface
*/
Expand Down
2 changes: 0 additions & 2 deletions Builder/MenuInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 0 additions & 2 deletions DependencyInjection/PdMenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
6 changes: 2 additions & 4 deletions Event/PdMenuEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -43,7 +41,7 @@ public function __construct(ItemInterface $menu)
*
* @return ItemInterface
*/
public function getMenu()
public function getMenu(): ItemInterface
{
return $this->menu;
}
Expand Down
2 changes: 0 additions & 2 deletions PdMenuBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 0 additions & 2 deletions Render/RenderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
9 changes: 5 additions & 4 deletions Render/TwigRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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)
{
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Twig/MenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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;

Expand Down Expand Up @@ -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>',
];

/**
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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 = '';
Expand Down

0 comments on commit 742a2a2

Please sign in to comment.