@param $module
@param $navigation
@param $group

@return mixed
516137
protected function findOrCreateGroup(Module $module, MenuBuilder $navigation, $group)
    {
        if (!$sub = $navigation->whereTitle($group)) {
            $sub = $navigation->dropdown($group, function () {
            }, 99, ['id' => $module->url(), 'icon' => 'fa fa-folder']);
        }

        return $sub;
    }
13055
private function getMiddleWareFromGroup(RouteGroup $group, array $middleWareList = [])
    {
        if ($group->middleWare) {
            $middleWareList = \array_merge($group->middleWare, $middleWareList);
        }
        if (\is_null($group->parentGroup)) {
            return $middleWareList;
        }
        return $this->getMiddleWareFromGroup($group->parentGroup, $middleWareList);
    }
1251886
public function getRouteGroup(string $groupName)
  {
    foreach ($this->routeGroups as $routeGroup)
    {
      if ( \strcasecmp($routeGroup->getName(),$groupName)==0 ) {
        return $routeGroup;
      }
    }

    return null;
  }
780129
public function extend_course_navigation($navigation, navigation_node $node) {
        global $PAGE;
        // if section is specified in course/view.php, make sure it is expanded in navigation
        if ($navigation->includesectionnum === false) {
            $selectedsection = optional_param('section', null, PARAM_INT);
            if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') &&
                    $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
                $navigation->includesectionnum = $selectedsection;
            }
        }

        // check if there are callbacks to extend course navigation
        parent::extend_course_navigation($navigation, $node);

        // We want to remove the general section if it is empty.
        $modinfo = get_fast_modinfo($this->get_course());
        $sections = $modinfo->get_sections();
        if (!isset($sections[0])) {
            // The general section is empty to find the navigation node for it we need to get its ID.
            $section = $modinfo->get_section_info(0);
            $generalsection = $node->get($section->id, navigation_node::TYPE_SECTION);
            if ($generalsection) {
                // We found the node - now remove it.
                $generalsection->remove();
            }
        }
    }
999496
public function load(string $moduleAndGroupName) : LoadedContentGroup
    {
        $loadedContentGroup = $this->actualContentLoaderService->load($moduleAndGroupName);

        return new LoadedContentGroup(
            $loadedContentGroup->getConfig(),
            $this->createPreviewContentGroup($loadedContentGroup->getContentGroup())
        );
    }
766626
public function run($group, $module, $model, $type = "", $mode = "default", $output = "view", $file = "", $customTemplate = "")
    {
        switch ($type)
        {
            case "controller":
                $this->generateController($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRoute($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "model":
                $this->generateModel($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "repository":
                $this->generateRepository($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "view":
                $this->generateView($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            default:
                $this->generateController($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRoute($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateModel($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRepository($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateView($group, $module, $model, $mode, $output, $file, $customTemplate);
        }
    }
617619
public function addModule($key, Module $module) {
        $this->_modules[$key] = $module;

        $module->setApplication($this);
        $module->bootstrap($this);

        if ($module instanceof Listener) {
            $this->on('mvc', $module);
        }

        return $module;
    }
630014
public function getNavigation()
    {
        /** @var Navigation $navigation */
        $navigation = null;
        $this->iterateAdmins(function(Admin $admin) use (&$navigation) {
            if (null === $navigation) {
                $navigation = $admin->getNavigation();

                return;
            }
            $navigation = $navigation->merge($admin->getNavigation());
        });

        return $navigation;
    }
449537
public function dispatch($action = [], $group = null)
    {

        // convert string type to array
        if (is_string($action)) {
            $action = [
                '_controller' => $action
            ];
        }


        // find and register route group
        $this->registerGroup($group, $action);

        // find and run middleware
        if ($middleware = $this->findMiddleware($action)) {
            app()->call([$this, 'middleware'], $middleware);
        }

        if (is_array($action)) {

            list($controller, $method, $namespace) = $this->findControllerAndMethod($action);

            // register the namespace
            isset($namespace) ? $this->setNamespace($namespace) : null;

            // create a controller instance
            $controller = $this->createControllerInstance($controller);

            // call the method
            $response = $this->callControllerMethod($controller, $method);
            return $this->handleResponse($response);

        } elseif ($action instanceof Closure) {
            return $this->handleResponse(app()->call($action, ParameterBag::getParameters()));
        } else {
            return false;
        }
    }
475954
private function buildExtensionsNavigation(&$nav)
    {
        // Loop over all the installed extensions to add in other navigation items
        $extensions = Symphony::ExtensionManager()->listInstalledHandles();

        foreach ($extensions as $e) {
            $extension = Symphony::ExtensionManager()->getInstance($e);
            $extension_navigation = $extension->fetchNavigation();

            if (is_array($extension_navigation) && !empty($extension_navigation)) {
                foreach ($extension_navigation as $item) {
                    $type = isset($item['children']) ? Extension::NAV_GROUP : Extension::NAV_CHILD;

                    switch ($type) {
                        case Extension::NAV_GROUP:
                            $index = General::array_find_available_index($nav, $item['location']);

                            // Actual group
                            $nav[$index] = self::createParentNavItem($index, $item);

                            // Render its children
                            foreach ($item['children'] as $child) {
                                $nav[$index]['children'][] = self::createChildNavItem($child, $e);
                            }

                            break;

                        case Extension::NAV_CHILD:
                            if (!is_numeric($item['location'])) {
                                // is a navigation group
                                $group_name = $item['location'];
                                $group_index = self::__navigationFindGroupIndex($nav, $item['location']);
                            } else {
                                // is a legacy numeric index
                                $group_index = $item['location'];
                            }

                            $child = self::createChildNavItem($item, $e);

                            if ($group_index === false) {
                                $group_index = General::array_find_available_index($nav, 0);

                                $nav_parent = self::createParentNavItem($group_index, $item);
                                $nav_parent['name'] = $group_name;
                                $nav_parent['children'] = array($child);

                                // add new navigation group
                                $nav[$group_index] = $nav_parent;
                            } else {
                                // add new location by index
                                $nav[$group_index]['children'][] = $child;
                            }

                            break;
                    }
                }
            }
        }
    }
979978
private function getModuleNavigation()
	{
		$modules = $this->getDoctrine()->getRepository(Module::class)->findBy([
			"active" => true,
			"displayed" => true
		]);
		
		foreach ($modules as $module) {
			$navigation = json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath
				($module->getPackageName()) . "/Resources/json/navigation.json"), true);
			
			foreach ($navigation["items"] as $item) {
				if ($this->get("ribs_admin.acess_rights")->testRight($item["right"])) {
					$this->nav[] = $item;
				}
			}
		}
	}
1235176
public function hasGroupPermission(Group $group)
    {
        $definitions = (new Query())->select("nav_id")->from("cms_nav_permission")->where(['group_id' => $group->id])->all();
        
        // the group has no permission defined, this means he can access ALL cms pages
        if (count($definitions) == 0) {
            return true;
        }
        
        foreach ($definitions as $permission) {
            if ($this->id == $permission['nav_id']) {
                return true;
            }
        }
        
        return false;
    }
256518
public function getModuleByAnchor($anchor)
    {
        foreach($this->lessons->modules as $mod) {
            if ( $mod->anchor == $anchor) return $mod;
        }
        return null;
    }
1125024
public function head($module, $controller): Link
    {
        return $this->addMap(RequestMethod::HEAD, $module, $controller);
    }
928795
private function buildNewContentGroup(ContentModule $module, ContentGroupDefinition $contentGroupDefinition, IClock $clock) : ContentGroup
    {
        $contentGroup = new ContentGroup($module->getName(), $contentGroupDefinition->name, $clock);

        foreach ($contentGroupDefinition->htmlAreas as $area) {
            $contentGroup->htmlContentAreas[] = new HtmlContentArea($area['name'], new Html(''));
        }

        foreach ($contentGroupDefinition->images as $area) {
            $contentGroup->imageContentAreas[] = new ImageContentArea($area['name'], new Image(''));
        }

        foreach ($contentGroupDefinition->textAreas as $area) {
            $contentGroup->textContentAreas[] = new TextContentArea($area['name'], '');
        }

        foreach ($contentGroupDefinition->fileAreas as $area) {
            $contentGroup->fileContentAreas[] = new FileContentArea($area['name'], new File(''));
        }

        foreach ($contentGroupDefinition->metadata as $item) {
            $contentGroup->metadata[] = new ContentMetadata($item['name'], '');
        }

        return $contentGroup;
    }
1094919
protected function FormUrl(Membergroup $group = null)
    {
        $args = array();
        if ($group)
        {
            $args['membergroup'] = $group->GetID();
        }
        return BackendRouter::ModuleUrl(new MembergroupForm(), $args);
    }
1119286
public function isGroupPermissionInheritNode(Group $group)
    {
        $definition = (new Query())->select("inheritance")->from("cms_nav_permission")->where(['group_id' => $group->id, 'nav_id' => $this->id])->one();
        
        if ($definition) {
            return (bool) $definition['inheritance'];
        }
        
        return false;
    }