Add the resource menu items.

@param ProductionMenuCollectionEvent $event The menu collection event.

@return void
488558
public function addResourceItem(ProductionMenuCollectionEvent $event): void
    {
        $menu = $event->getMenu();
        $group = $event->getGroup();

        // Create resource menu item.
        $resources = $this->factory->createItem('menu_item.resources', [
            'route' => 'bkstg_resource_index',
            'routeParameters' => ['production_slug' => $group->getSlug()],
            'extras' => [
                'icon' => 'file',
                'translation_domain' => BkstgResourceBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($resources);

        // If this user is an editor create the post and archive items.
        if ($this->auth->isGranted('GROUP_ROLE_EDITOR', $group)) {
            $resources_resources = $this->factory->createItem('menu_item.resources_resources', [
                'route' => 'bkstg_resource_index',
                'routeParameters' => ['production_slug' => $group->getSlug()],
                'extras' => ['translation_domain' => BkstgResourceBundle::TRANSLATION_DOMAIN],
            ]);
            $resources->addChild($resources_resources);

            $archive = $this->factory->createItem('menu_item.resources_archive', [
                'route' => 'bkstg_resource_archive',
                'routeParameters' => ['production_slug' => $group->getSlug()],
                'extras' => ['translation_domain' => BkstgResourceBundle::TRANSLATION_DOMAIN],
            ]);
            $resources->addChild($archive);
        }
    }
519333
public function onMenuTree(MenuEvent $event)
    {
        if (!$event->hasSite()) {
            return;
        }

        $deleted = [];
        $changed = [];

        foreach ($event->getDeletedItems() as $item) {
            $deleted[] = $item->getNodeId();
        }
        if ($deleted) {
            // @todo
            //  if node is not present on site, we should clean up the references
            //  except for some types such as news (list by type)
        }

        foreach ($event->getTree()->getAll() as $item) {
            $changed[] = $item->getNodeId();
        }
        if ($changed) {
            $this->nodeManager->createReferenceBulkInSite($event->getSite()->getId(), $changed);
        }
    }
299616
protected function createAdminMenu(): void
    {
        $menu = $this->menu();
        $events = $this->app->make('events');

        $handlers = [
            UserMenuHandler::class,
            ExtensionMenuHandler::class,
            SettingMenuHandler::class,
        ];

        $menu->add('home')
            ->title(\trans('orchestra/foundation::title.home'))
            ->link($this->handles('orchestra::/'))
            ->icon('home');

        foreach ($handlers as $handler) {
            $events->listen('orchestra.started: admin', $handler);
        }
    }
226953
public function addProductionMenuItems(MenuCollectionEvent $event): void
    {
        // We only operate on group member users.
        $user = $this->token_storage->getToken()->getUser();
        if (!$user instanceof GroupMemberInterface) {
            return;
        }

        // Create productions menu dropdown item.
        $productions = $this->factory->createItem('menu_item.productions', [
            'extras' => ['translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN],
        ]);

        $items = [];
        foreach ($user->getMemberships() as $membership) {
            // Get the group for this membership, if not a production skip out.
            $group = $membership->getGroup();

            // If the membership and production are active and not expired.
            if ($membership->isActive()
                && !$membership->isExpired()
                && $group->isActive()
                && !$group->isExpired()) {
                // The membership is good, add a menu item.
                $items[] = $this->factory->createItem($membership->getGroup()->getName(), [
                    'route' => 'bkstg_production_read',
                    'routeParameters' => ['production_slug' => $membership->getGroup()->getSlug()],
                    'extras' => ['translation_domain' => false],
                ]);
            }
        }

        if (0 === count($user->getMemberships())) {
            $productions->addChild($this->factory->createItem('menu_item.no_productions', [
                'uri' => '#',
                'extras' => [
                    'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
                ],
            ]));
        } else {
            // Add all children (in alpha order) to production item.
            usort($items, function ($a, $b) {
                return strcasecmp($a->getLabel(), $b->getLabel());
            });
            $productions->setChildren($items);
        }

        // Add the production menu item to the main menu.
        $menu = $event->getMenu();
        $menu->addChild($productions);
    }
50447
public function rights(ResourceActionEvent $event)
    {
        // forward to the resource type
        $options = [];

        $params = $event->getOptions();

        if (isset($params['recursive']) && 'true' === $params['recursive']) {
            $options[] = Options::IS_RECURSIVE;
        }

        $data = $event->getData();
        $this->crud->update(ResourceNode::class, $data, $options);
        $this->lifecycleManager->rights($event->getResourceNode(), $event->getData());

        $event->setResponse(new JsonResponse(
            $this->serializer->serialize($event->getResourceNode())
        ));
    }
107629
public function process(ContainerBuilder $container): void
    {
        if (!$container->has('ngsite.menu.factory.location')) {
            return;
        }

        $factory = $container->findDefinition('ngsite.menu.factory.location');

        $extensions = [];

        foreach ($container->findTaggedServiceIds('ngsite.menu.factory.location.extension') as $extension => $tags) {
            foreach ($tags as $tag) {
                $priority = (int) ($tag[0]['priority'] ?? 0);
                $extensions[$priority][] = new Reference($extension);
            }
        }

        krsort($extensions);
        $extensions = array_merge(...$extensions);

        $factory->replaceArgument(2, $extensions);
    }
1036148
public function addMenuItem(Request $request, array $item, MenuItem $menu)
    {
        $attributes = array();

        // if the menu item has a name, add it as a css class.
        if ($name = $item['name']) {
            $attributes['class'] = $name;
        }
        if (empty($item['path'])) {
            $uri = null;
        } elseif (preg_match('!^(?:https?://|mailto:)!', $item['path'])) {
            $uri = $item['path'];
        } else {
            $baseUrl = $request->getBaseUrl();
            $uri = $baseUrl . '/' . ltrim($item['path'], '/');
        }

        $menuItem = $menu->addChild(
            $item['id'],
            array(
                'uri' => $uri,
                'attributes' => $attributes,
                'label' => $item['title']
            )
        );

        if (!empty($item['json_data'])) {
            $item['json_data'] = @json_decode($item['json_data']);
        }

        $menuItem->setExtras($item);
        return $menuItem;
    }
731411
public function onLoad(LoadResourceEvent $event)
    {
        /** @var File $resource */
        $resource = $event->getResource();
        $path = $this->filesDir.DIRECTORY_SEPARATOR.$resource->getHashName();

        $additionalFileData = [];

        /** @var LoadFileEvent $loadEvent */
        $loadEvent = $this->eventDispatcher->dispatch(
            $this->generateEventName($resource->getResourceNode(), 'load'),
            LoadFileEvent::class,
            [$resource, $path]
        );

        if ($event->isPopulated()) {
            $additionalFileData = $loadEvent->getData();
        } else {
            // no listener found, try to dispatch the fallback event
            /** @var LoadFileEvent $fallBackEvent */
            $fallBackEvent = $this->eventDispatcher->dispatch(
                $this->generateEventName($resource->getResourceNode(), 'load', true),
                LoadFileEvent::class,
                [$resource, $path]
            );

            if ($fallBackEvent->isPopulated()) {
                $additionalFileData = $fallBackEvent->getData();
            }
        }

        $event->setData([
            // common file data
            'file' => array_merge(
                $additionalFileData,
                // standard props are in 2nd to make sure custom file serializer doesn't override them
                $this->serializer->serialize($resource)
            ),
        ]);
    }
1126655
public function onGetDatabaseResources(GetDatabaseResourcesEvent $event)
    {
        // prevent errors on command such as cache:clear if doctrine schema has not been updated yet
        if (StorageInterface::STORAGE_ORM == $this->storageType && !$this->storage->translationsTablesExist()) {
            $resources = array();
        } else {
            $resources = $this->storage->getTransUnitDomainsByLocale();
        }

        $event->setResources($resources);
    }
456787
protected function addLabelChannels(ResourceEvent $event)
    {
        $nodeId = $event->getResourceIdList()[0];
        $node   = $this->entityManager->getStorage('node')->load($nodeId);
        $items  = field_get_items('node', $node, 'labels');

        if ($items) {
            foreach ($items as $item) {
                $event->addResourceChanId('label', $item['tid']);
            }
        }
    }
1139507
public function onCreate(CreateResourceEvent $event)
    {
        $request = $this->container->get('request_stack')->getMasterRequest();
        $form = $this->container->get('form.factory')->create(WebsiteType::class, new Website());
        $form->handleRequest($request);
        if ($form->isValid()) {
            $website = $form->getData();
            $event->setResources([$website]);
        } else {
            $content = $this->container->get('templating')->render(
                'ClarolineCoreBundle:resource:create_form.html.twig',
                [
                    'form' => $form->createView(),
                    'resourceType' => 'icap_website',
                ]
            );
            $event->setErrorFormContent($content);
        }
        $event->stopPropagation();
    }
920142
public function addSettingsItem(ProductionMenuCollectionEvent $event): void
    {
        $menu = $event->getMenu();
        $group = $event->getGroup();

        // Should only be available to admins.
        if (!$this->auth->isGranted('GROUP_ROLE_ADMIN', $group)) {
            return;
        }

        // Create settings menu items.
        $settings = $this->factory->createItem('menu_item.settings', [
            'route' => 'bkstg_production_settings',
            'routeParameters' => ['production_slug' => $group->getSlug()],
            'extras' => [
                'icon' => 'wrench',
                'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($settings);

        $general = $this->factory->createItem('menu_item.general', [
            'route' => 'bkstg_production_settings',
            'routeParameters' => ['production_slug' => $group->getSlug()],
            'extras' => [
                'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $settings->addChild($general);
    }
758456
public function addContextual($event)
    {
        $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar();

        //if there is a template, we add the link in the top bar
        $bottomRightNavbar->addChild('menu.page.settings',
            [
                'route'           => 'victoire_business_template_edit',
                'routeParameters' => ['id' => $event->getPage()->getId()],
                'linkAttributes'  => [
                    'class' => 'v-btn v-btn--sm v-btn--transparent',
                ],
            ]
        )->setLinkAttribute('data-toggle', 'vic-modal');
        $bottomRightNavbar->addChild('menu.page.seoSettings',
            [
                'route'           => 'victoire_seo_pageSeo_settings',
                'routeParameters' => ['id' => $event->getPage()->getId()],
                'linkAttributes'  => [
                    'class' => 'v-btn v-btn--sm v-btn--transparent',
                ],
            ]
        )->setLinkAttribute('data-toggle', 'vic-modal');
    }
1230746
public function addItem($name, \SlimStarter\Menu\MenuItem $item){
        $this->items[$name] = $item;
    }
806351
public function buildFromEvent(Event $event)
    {
        $this->setEvent($event);

        $configs = $this->getConfigFilesByComposer();
        $this->addFindersByConfigs($configs);

        // We have to initialize composer autoload
        require_once 'vendor/autoload.php';

        $this->build();
    }
599144
public function initBackendMenuMainItems(Event $event)
    {
        /** @var Menu $menu the "backend.main" Nav instance */
        $menu = $event->subject();

        $menu
            ->addMenuItem([
                'alias' => 'cms-pages',
                'name' => __d('wasabi_cms', 'Pages'),
                'parent' => 'content',
                'priority' => 1,
                'url' => [
                    'plugin' => 'Wasabi/Cms',
                    'controller' => 'Pages',
                    'action' => 'index'
                ]
            ])
            ->addMenuItem([
                'alias' => 'menus',
                'name' => __d('wasabi_cms', 'Menus'),
                'priority' => 2000,
                'url' => [
                    'plugin' => 'Wasabi/Cms',
                    'controller' => 'Menus',
                    'action' => 'index'
                ],
                'icon' => 'icon-menu',
            ])
            ->addMenuItem([
                'alias' => 'settings_theme',
                'name' => __d('wasabi_cms', 'Theme'),
                'priority' => 350,
                'parent' => 'settings',
                'url' => [
                    'plugin' => 'Wasabi/Cms',
                    'controller' => 'Settings',
                    'action' => 'theme'
                ],
                'matchAction' => true
            ])
            ->addMenuItem([
                'alias' => 'settings_seo',
                'name' => __d('wasabi_cms', 'SEO'),
                'priority' => 400,
                'parent' => 'settings',
                'url' => [
                    'plugin' => 'Wasabi/Cms',
                    'controller' => 'Settings',
                    'action' => 'seo'
                ],
                'matchAction' => true
            ]);;
    }
1270360
public function setCreatedResourceLink(TimelineLinkEvent $event): void
    {
        $action = $event->getAction();

        if ('created_resource' != $action->getVerb()) {
            return;
        }

        $production = $action->getComponent('indirectComplement')->getData();
        $resource = $action->getComponent('directComplement')->getData();
        $event->setLink($this->url_generator->generate('bkstg_resource_read', [
            'id' => $resource->getId(),
            'production_slug' => $production->getSlug(),
        ]));
    }