Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/bundles/CoreBundle/Menu/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/CoreBundle/Menu/MenuBuilder.php
<?php

namespace Mautic\CoreBundle\Menu;

use Knp\Menu\FactoryInterface;
use Knp\Menu\Loader\ArrayLoader;
use Knp\Menu\Matcher\MatcherInterface;
use Mautic\CoreBundle\CoreEvents;
use Mautic\CoreBundle\Event\MenuEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class MenuBuilder
{
    /**
     * @var \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
     */
    private $dispatcher;

    public function __construct(
        private FactoryInterface $factory,
        private MatcherInterface $matcher,
        EventDispatcherInterface $dispatcher,
        private MenuHelper $menuHelper
    ) {
        $this->dispatcher = $dispatcher;
    }

    /**
     * @return mixed
     */
    public function __call($name, $arguments)
    {
        $name = str_replace('Menu', '', $name);

        return $this->buildMenu($name);
    }

    /**
     * Used by breadcrumbs to determine active link.
     *
     * @param \Knp\Menu\ItemInterface $menu
     * @param string                  $forRouteUri
     * @param string                  $forRouteName
     *
     * @return \Knp\Menu\ItemInterface|null
     */
    public function getCurrentMenuItem($menu, $forRouteUri, $forRouteName)
    {
        try {
            /** @var \Knp\Menu\ItemInterface $item */
            foreach ($menu as $item) {
                if ('current' == $forRouteUri && $this->matcher->isCurrent($item)) {
                    // current match
                    return $item;
                } elseif ('current' != $forRouteUri && $item->getUri() == $forRouteUri) {
                    // route uri match
                    return $item;
                } elseif (!empty($forRouteName) && $forRouteName == $item->getExtra('routeName')) {
                    // route name match
                    return $item;
                }

                if ($item->getChildren() && $current_child = $this->getCurrentMenuItem($item, $forRouteUri, $forRouteName)) {
                    return $current_child;
                }
            }
        } catch (\Exception) {
            // do nothing
        }

        return null;
    }

    /**
     * @return mixed
     */
    private function buildMenu($name)
    {
        static $menus = [];

        if (!isset($menus[$name])) {
            $loader = new ArrayLoader($this->factory);

            // dispatch the MENU_BUILD event to retrieve bundle menu items
            $event = new MenuEvent($this->menuHelper, $name);
            $this->dispatcher->dispatch($event, CoreEvents::BUILD_MENU);

            $menuItems    = $event->getMenuItems();

            // KNP Menu explicitly requires a menu name since v3
            if (empty($menuItems['name'])) {
                $menuItems['name'] = $name;
            }
            $menus[$name] = $loader->load($menuItems);
        }

        return $menus[$name];
    }
}

Spamworldpro Mini