Build menu.

@param string $menuCode Menu code

@return MenuInterface Menu

@throws Exception
434620
private function buildMenuFromRepository($menuCode)
    {
        $menu = $this
            ->menuRepository
            ->findOneBy([
                'code' => $menuCode,
                'enabled' => true,
            ]);

        if (!($menu instanceof MenuInterface)) {
            throw new Exception(sprintf(
                'Menu "%s" not found',
                $menuCode
            ));
        }

        $this
            ->menuObjectManager
            ->detach($menu);

        return $menu;
    }
208814
protected function getQueryHandlerConfiguration(string $code): QueryHandlerConfigurationInterface
    {
        if (!array_key_exists($code, $this->queryHandlerConfigurations)) {
            return $this->buildQueryHandlerConfiguration($code);
        }

        return $this->queryHandlerConfigurations[$code];
    }
594271
protected function setHttpCode($httpCode = null)
    {
        if ($httpCode !== null) {
            $this->httpCode = (int) $httpCode;

            if (!HttpCode::exists($this->httpCode)) {
                throw new \DomainException('Http Code does not exist! (code: ' . $this->httpCode . ')');
            }
        }

        return $this;
    }
1078075
protected static function _getMenuItemObject(array $data): MenuItemInterface
    {
        $itemType = !empty($data['type']) ? $data['type'] : BaseMenuItem::DEFAULT_MENU_ITEM_TYPE;

        $className = __NAMESPACE__ . '\\' . BaseMenuItem::MENU_ITEM_CLASS_PREFIX . ucfirst(Inflector::camelize($itemType));
        $interface = __NAMESPACE__ . '\\' . BaseMenuItem::MENU_ITEM_INTERFACE;

        if (class_exists($className) && in_array($interface, class_implements($className))) {
            return new $className();
        }

        throw new InvalidArgumentException("Unknown menu item type [$itemType]!");
    }
1318162
public function build(MenuEntry $root)
    {
        // Top level header for ContentTypes
        $contentRoot = $root->add(
            MenuEntry::create('content', '')
                ->setLabel(Trans::__('general.phrase.content'))
                ->setIcon('fa:file-text')
                ->setPermission('dashboard')
        );
        $mainContentRoot = $contentRoot->add(
            MenuEntry::create('main')
                ->setPermission('dashboard')
        );

        foreach ($this->contentTypes as $name => $contentType) {
            if ($contentType->get('show_in_menu') !== true) {
                $this->addGroupedMenu($mainContentRoot, $contentType);
            } else {
                $this->addContentType($mainContentRoot, $name, $contentType);
            }
        }

        $this->fillGroupedMenus($mainContentRoot);

        return $root;
    }
842173
public function getMenu(string $menuClass, $options = []): ItemInterface
    {
        // Merge Options
        $options = array_merge($this->defaultOptions, $options);

        // Get Menu
        $menu = $this->container->has($menuClass) ? $this->container->get($menuClass) : new $menuClass();

        // Render
        if ($menu instanceof MenuInterface) {
            return $this->itemProcess->processMenu($menu->createMenu($options), $options);
        }

        return false;
    }
316479
public function tokenize($code)
    {
        $this->tokens = array();
        $lines        = preg_split('/\r?\n/', $code);
        $number       = 0;

        foreach ($lines as $number => $fragment) {
            $this->processLine($number + 1, $fragment);
            $this->tokens[] = new Token(self::TOKEN_EOL, null, $number + 1);
        }
        $this->tokens[] = new Token(self::TOKEN_EOF, null, $number + 1);

        return new TokenStream($this->tokens);
    }
1252192
public function setHttpResponseCode($code)
    {
        if (!is_int($code) || (100 > $code) || (599 < $code)) {
            throw new \Exception('Invalid HTTP response code');
        }

        $this->_isRedirect = (300 <= $code) && (307 >= $code);
        $this->_httpResponseCode = $code;
        return $this;
    }
361243
public function menuAction()
    {
        $loader = $this->get('phlexible_gui.menu.loader');
        $items = $loader->load();
        $data = $items->toArray();

        return new JsonResponse($data);
    }
924452
public static function getLocaleByCode($languageCode, $countryCode = null) {
		$class = 'Dater\Locale\\' . ucfirst(strtolower($languageCode)) . ($countryCode ? ucfirst(strtolower($countryCode)) : '');
		if(!class_exists($class)) {
			throw new \Exception('Unknown locale code. Class "' . $class . '" not found.');
		}
		return new $class();
	}
489244
public function wd($dir = null, $code = E_USER_WARNING){
		if(null !== $dir && is_dir($dir)){
			$this->wd = $dir;
			if(chdir($dir) === false){
			    throw new \Exception('Cannot change to directory '.$dir.' in '.__METHOD__, $code);
				return $this;
			}
		}else{
			$dir = $this->wd;
		}
		return $this;
	}
670226
private function buildMenu()
    {
        foreach ($this->menuEntries as $menuEntry) {
            $this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4], $menuEntry[5], $menuEntry[6]);
        }
    }
814833
public function createCode(TokenInterface $code): TokenInterface
    {
        try {
            $now    = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $schema = $this->getDatabaseSchema();
            $values = [
                $schema->getTokensClientIdentityColumn() => $code->getClientIdentifier(),
                $schema->getTokensUserIdentityColumn()   => $code->getUserIdentifier(),
                $schema->getTokensCodeColumn()           => $code->getCode(),
                $schema->getTokensIsScopeModified()      => $code->isScopeModified(),
                $schema->getTokensCodeCreatedAtColumn()  => $now,
            ];

            $tokenIdentifier = null;
            if (empty($scopeIdentifiers = $code->getScopeIdentifiers()) === false) {
                $this->inTransaction(function () use ($values, $scopeIdentifiers, &$tokenIdentifier) {
                    $this->createResource($values);
                    $tokenIdentifier = $this->getLastInsertId();
                    $this->bindScopeIdentifiers($tokenIdentifier, $scopeIdentifiers);
                });
            } else {
                $this->createResource($values);
                $tokenIdentifier = $this->getLastInsertId();
            }

            $code->setIdentifier($tokenIdentifier)->setCodeCreatedAt($now);

            return $code;
        } catch (RepositoryException $exception) {
            $message = 'Token code creation failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
482487
public function setExitCode($exitCode)
    {
        $this->exitCode = (int) $exitCode;

        $r = new \ReflectionProperty($this->error, 'code');
        $r->setAccessible(true);
        $r->setValue($this->error, $this->exitCode);
    }
869791
protected function renderControlWrapper ($renderedCode) {
		$wrapperReplacement = '{control}';
		$wrapper = mb_strpos($wrapperReplacement, $this->wrapper) !== FALSE 
			? $this->wrapper 
			: $wrapperReplacement;
		return str_replace($wrapperReplacement, $renderedCode, $wrapper);
	}
154088
public function setStatusCode($code)
    {
        $code = (int) $code;

        if (!array_key_exists($code, $this->validStatusCodes)) {
            throw new Exceptions\InvalidStatusCodeException(
                "'$code' is an invalid status code"
            );
        }

        $this->statusCode = $code;

        return $this;
    }
1067136
public function subMenu($key = null, $menuItem = null)
    {
        if (null === $menuItem) {
            return $this->subMenu;
        }

        if (is_callable($menuItem)) {
            $menu = new AdminMenu($menuItem);
            $this->subMenu[$key] = $menu;
        } else {
            $this->subMenu[$key] = $menuItem;
        }

        return $this;
    }