Returns the main menu of the CMS.  This is also used by init()
to work out which sections the user has access to.

@param bool $cached
@return SS_List
344970
public function MainMenu($cached = true)
    {
        if (!isset($this->_cache_MainMenu) || !$cached) {
            // Don't accidentally return a menu if you're not logged in - it's used to determine access.
            if (!Security::getCurrentUser()) {
                return new ArrayList();
            }

            // Encode into DO set
            $menu = new ArrayList();
            $menuItems = CMSMenu::get_viewable_menu_items();

            // extra styling for custom menu-icons
            $menuIconStyling = '';

            if ($menuItems) {
                /** @var CMSMenuItem $menuItem */
                foreach ($menuItems as $code => $menuItem) {
                    // alternate permission checks (in addition to LeftAndMain->canView())
                    if (isset($menuItem->controller)
                        && $this->hasMethod('alternateMenuDisplayCheck')
                        && !$this->alternateMenuDisplayCheck($menuItem->controller)
                    ) {
                        continue;
                    }

                    $linkingmode = "link";

                    if ($menuItem->controller && get_class($this) == $menuItem->controller) {
                        $linkingmode = "current";
                    } elseif (strpos($this->Link(), $menuItem->url) !== false) {
                        if ($this->Link() == $menuItem->url) {
                            $linkingmode = "current";

                            // default menu is the one with a blank {@link url_segment}
                        } elseif (singleton($menuItem->controller)->config()->get('url_segment') == '') {
                            if ($this->Link() == AdminRootController::admin_url()) {
                                $linkingmode = "current";
                            }
                        } else {
                            $linkingmode = "current";
                        }
                    }

                    // already set in CMSMenu::populate_menu(), but from a static pre-controller
                    // context, so doesn't respect the current user locale in _t() calls - as a workaround,
                    // we simply call LeftAndMain::menu_title() again
                    // if we're dealing with a controller
                    if ($menuItem->controller) {
                        $title = LeftAndMain::menu_title($menuItem->controller);
                    } else {
                        $title = $menuItem->title;
                    }

                    // Provide styling for custom $menu-icon. Done here instead of in
                    // CMSMenu::populate_menu(), because the icon is part of
                    // the CMS right pane for the specified class as well...
                    $iconClass = '';
                    $hasCSSIcon = false;
                    if ($menuItem->controller) {
                        $menuIcon = LeftAndMain::menu_icon_for_class($menuItem->controller);

                        if (!empty($menuIcon)) {
                            $menuIconStyling .= $menuIcon;
                            $hasCSSIcon = true;
                        } else {
                            $iconClass = LeftAndMain::menu_icon_class_for_class($menuItem->controller);
                        }
                    } else {
                        $iconClass = $menuItem->iconClass;
                    }

                    $menu->push(new ArrayData(array(
                        "MenuItem" => $menuItem,
                        "AttributesHTML" => $menuItem->getAttributesHTML(),
                        "Title" => $title,
                        "Code" => $code,
                        "Icon" => strtolower($code),
                        "IconClass" => $iconClass,
                        "HasCSSIcon" => $hasCSSIcon,
                        "Link" => $menuItem->url,
                        "LinkingMode" => $linkingmode
                    )));
                }
            }
            if ($menuIconStyling) {
                Requirements::customCSS($menuIconStyling);
            }

            $this->_cache_MainMenu = $menu;
        }

        return $this->_cache_MainMenu;
    }
602696
private function getCached() {
        if (isset($_GET['noCache'])) return null;
        $cacheDir = DATA . 'select' . DIRECTORY_SEPARATOR;
        if (!is_dir($cacheDir)) mkdir($cacheDir, 0777, true);

        $cache = $cacheDir . base64_encode($this->getName()) . '.php';
        if (!is_readable($cache)) return null;
        $cached = include $cache;
        return $this->decode($cached[$this->encode($this->query . serialize($this->values))]);
    }
694804
static function cacheDirectory()
    {
        $cacheDirectory =& $GLOBALS['eZTemplateTreeCacheDirectory'];
        if ( !isset( $cacheDirectory ) )
        {
            $cacheDirectory = eZDir::path( array( eZSys::cacheDirectory(), 'template/tree' ) );
        }
        return $cacheDirectory;
    }
992744
public function index(Content $content)
    {
        return $content
            ->header(trans('admin.menu'))
            ->description(trans('admin.list'))
            ->row(function (Row $row) {
                $row->column(6, $this->treeView()->render());

                $row->column(6, function (Column $column) {
                    $form = new \Encore\Admin\Widgets\Form();
                    $form->action(admin_base_path('auth/menu'));

                    $menuModel = config('admin.database.menu_model');
                    $permissionModel = config('admin.database.permissions_model');
                    $roleModel = config('admin.database.roles_model');

                    $form->select('parent_id', trans('admin.parent_id'))->options($menuModel::selectOptions());
                    $form->text('title', trans('admin.title'))->rules('required');
                    $form->icon('icon', trans('admin.icon'))->default('fa-bars')->rules('required')->help($this->iconHelp());
                    $form->text('uri', trans('admin.uri'));
                    $form->multipleSelect('roles', trans('admin.roles'))->options($roleModel::all()->pluck('name', 'id'));
                    if ((new $menuModel())->withPermission()) {
                        $form->select('permission', trans('admin.permission'))->options($permissionModel::pluck('name', 'slug'));
                    }
                    $form->hidden('_token')->default(csrf_token());

                    $column->append((new Box(trans('admin.new'), $form))->style('success'));
                });
            });
    }
154025
static function getMenu($users = [])
    {
        $menuTables = self::getAll();
        if ($users && $users['gid'] !== '99') {
            $roleAuths = CommonRoleModel::getInfo($users['gid']);
            $auths = isset($roleAuths['auths']) ? $roleAuths['auths'] : array();
            foreach ($menuTables as $key => $value) {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if(isset($val['items']) && $val['items']) {
                            foreach ($val['items'] as $ks => $v) {
                                if (isset($v['url']) && !in_array($ks, (array) $auths))  {   
                                    unset($menuTables[$key]['items'][$k]['items'][$ks]);
                                } 
                            }
                        }  else if (isset($val['url']) && !in_array($k, (array) $auths)) {   
                            unset($menuTables[$key]['items'][$k]);
                        } 
                    }
                } else {
                    unset($menuTables[$key]);
                }
            }
        }
        foreach ($menuTables as $key => $value) {
            if (isset($value['items']) && empty($value['items'])) {
                unset($menuTables[$key]);
            } else if (isset($value['items']) && !$value['items']) {
                unset($menuTables[$key]);
            } else {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if (isset($val['items']) && empty($val['items'])) {
                            unset($menuTables[$key]['items'][$k]);
                        } else if ((!isset($val['items']) || !$val['items']) && !isset($val['url'])) {
                            unset($menuTables[$key]['items'][$k]);
                        }
                    }
                }   
            }
        }
        foreach ($menuTables as $key => $value) {
            if ((isset($value['items']) && empty($value['items'])) || (!isset($value['items']) || !$value['items'])) {
                unset($menuTables[$key]);
            }
        }
        return $menuTables;
    }
646563
public function get_menu( $menu, $args ) {

		if ( $this->should_cache_menu( $args ) ) {
			$cached_menu = get_transient( $this->menu_key( $args ) );
			if ( is_string( $cached_menu ) ) {
				return $cached_menu;
			}
		}

		return $menu;
	}
531104
public function getCacheData($pCoord)
    {
        if ($pCoord === $this->currentObjectID) {
            return $this->currentObject;
        }
        $this->storeData();

        //    Check if the entry that has been requested actually exists
        if (!isset($this->cellCache[$pCoord])) {
            //    Return null if requested entry doesn't exist in cache
            return null;
        }

        //    Set current entry to the requested entry
        $this->currentObjectID = $pCoord;
        $this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
        //    Re-attach this as the cell's parent
        $this->currentObject->attach($this);

        //    Return requested entry
        return $this->currentObject;
    }
66387
protected function formatCached($cached)
    {
        $components = [];

        foreach ($cached as $name => $component) {
            $path = $this->config('paths.components') . '/' . $name;

            $components[$name] = new Component($this->app, $name, $path);
        }

        return $components;
    }
698283
public function getCacheDir(): string
    {
        if ($this->_cache_dir === null)
            $this->_cache_dir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache');

        return $this->_cache_dir;
    }
56938
public function getSiteByRootPageId($rootPageId)
    {
        $cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId;

        $methodResult = $this->runtimeCache->get($cacheId);
        if (!empty($methodResult)) {
            return $methodResult;
        }

        $methodResult = $this->buildSite($rootPageId);
        $this->runtimeCache->set($cacheId, $methodResult);

        return $methodResult;
    }
156294
public function get_css_cached_content() {

        $key = $this->get_css_cache_key();
        $cache = cache::make('core', 'postprocessedcss');

        return $cache->get($key);
    }
303253
public function getMainItem()
    {
        $menuPage = $this->menuBuilder->getTopNavbar()->getChild('menu.page');

        if ($menuPage) {
            return $menuPage;
        } else {
            return $this->menuBuilder->createDropdownMenuItem(
                $this->menuBuilder->getTopNavbar(),
                'menu.page'
            );
        }
    }
275451
public function getCurrent()
    {
        if ($this->currentCache !== null) {
            return $this->currentCache;
        }
        /* @var $active MenuItem */
        $active = null;
        do {
            /* @var MenuItem[] $children */
            $children = $this->getChildren($active);
            $foundActiveChild = false;
            foreach ($children as $child) {
                if ($child->getActive()) {
                    $foundActiveChild = true;
                    $active = $child;
                    break;
                }
            }
        } while ($foundActiveChild);
        $this->currentCache = $active;

        return $active;
    }
315372
public function getItem($cacheId, & $success = null)
    {
        $cacheId = $this->normalizeKey($cacheId);

        /** @var $cache \Zend\Cache\Storage\Adapter\AbstractAdapter */
        $cache    = $this->cache;
        $casToken = null;

        try {
            $content = $cache->getItem($cacheId, $success, $casToken);
        } catch (ZendException\ExceptionInterface $ex) {
            $success = false;

            return null;
        }

        if (!$cache->hasPlugin(new Serializer())) {
            $content = unserialize($content);
        }

        return $content;
    }
1243367
public function getMenu($agentid=''){
	    if ($agentid=='') {
	    	$agentid=$this->agentid;
	    }
		if (!$this->access_token && !$this->checkAuth()) return false;
		$result = $this->http_get(self::API_URL_PREFIX.self::MENU_GET_URL.'access_token='.$this->access_token.'&agentid='.$agentid);
		if ($result)
		{
			$json = json_decode($result,true);
			if (!$json || isset($json['errcode']) || $json['errcode']!=0) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'];
				return false;
			}
			return $json;
		}
		return false;
	}
1117619
public static function getUrlByMenuId($menuId)
    {
        $record = static::find()
            ->findByMenuId($menuId)
            ->innerJoinWith('menuUrl')
            ->one();

        $return = [];
        if ($record) {
            $return = $record->getMenuUrlData();
        }

        return $return;
    }
1054678
public function getCacheByKey($cacheKey, $confCache, $getForce = false)
	{
	    // only when in front mode
	    if ($this->getRenderMode() != 'front' && !$getForce)
	        return null;
	    
	    $active = $this->isCacheConfActive($confCache);
	    if ($active)
	    {
	        $cache = $this->getServiceLocator()->get($confCache);

	        if ($cache->hasItem($cacheKey))
	        {
	            $itemValue = $cache->getItem($cacheKey);
	            return $itemValue;
	        }
	    }
	    
	    return null;
	}