Menu items getter using database table.

@param \Cake\Datasource\EntityInterface $menu Menu entity
@return mixed[]
325423
protected function getMenuItemsFromTable(EntityInterface $menu): array
    {
        $query = $this->MenuItems->find('threaded', [
            'conditions' => ['MenuItems.menu_id' => $menu->id],
            'order' => ['MenuItems.lft']
        ]);

        if ($query->isEmpty()) {
            return [];
        }

        $result = [];
        $count = 0;
        foreach ($query->all() as $entity) {
            $item = $this->getMenuItem($menu, $entity->toArray(), ++$count);

            if (empty($item)) {
                continue;
            }
            $result[] = $item;
        }

        return $result;
    }
609724
public function getChildren(MenuItem $parent = null)
    {
        if ($parent == null) {
            return $this->getTopChildren();
        }
        $result = [];
        foreach ($this->adaptors as $menuAdaptor) {
            $menuAdaptor->adaptChildren($this, $result, $parent, $this->getRequest());
        }

        return $result;
    }
346675
private function getChildIds(ModelInterface $model)
    {
        if (null === ($childCollections = $model->getMeta($model::CHILD_COLLECTIONS))) {
            return [];
        }

        $ids = [ModelId::fromModel($model)->getSerialized()];

        $childIds = [];
        foreach ($childCollections as $collection) {
            foreach ($collection as $child) {
                $childIds[] = $this->getChildIds($child);
            }
        }

        return \array_merge($ids, ...$childIds);
    }
616169
public static function getPackageMenuItems($menu, $user)
    {
        $packageItems = [];

        foreach ($menu['items'] as $i) {
            $item = new Item();
            $item->text = array_key_exists('trans', $i) ? __($i['trans']) : $i['text'];
            $item->url = array_key_exists('route', $i) ? route($i['route']) : url($i['link']);

            if (array_key_exists('permission', $i) && !$user->superAdmin()) {
                if (!$user->hasPermission($i['permission'])) {
                    continue;
                }
            }

            array_push($packageItems, $item);
        }

        return $packageItems;
    }
1222239
public static function fetchArray(EntityInterface $entity): array
    {
        if(!defined(get_class($entity)."::FIELDS"))
            return [];
        elseif(is_array($entity::FIELDS))
            $fields = $entity::FIELDS;
        else
            $fields = json_decode($entity::FIELDS, true);

        $ret = [];
        foreach($fields as $key=>$value) {
            $ret[
                \Stringy\StaticStringy::upperCamelize($key)
            ] = $value;
        }
        
        return $ret;
    }
1357424
public static function getMenuItems($key)
    {
        $menuItems = [];

        $storedMenuItems = Cache::remember('', 10, function () {
            return MenuItem::all();
        });

        foreach ($storedMenuItems as $menuItem) {
            $menuItems[$menuItem->{$key}] = $menuItem;
        }

        return $menuItems;
    }
584862
private function getOptions(MethodInterface $method)
    {
        if ($method->getMethod() == $method::GET) {
            return [
                'query' => $method->getAttributes(),
            ];
        }

        return [
            'headers' => [
                'Content-Type' => 'application/json',
            ],
            'body' => json_encode(
                $this->prepareAttributes($method->getAttributes()),
                JSON_FORCE_OBJECT
            )
        ];
    }
341436
public function menuLinks($menu = [])
    {
        if (empty($menu)) {
            $menu = $this->menu();
        }

        $links = [];

        foreach ($menu as $item) {
            if (!empty($item['children'])) {
                $links = array_merge($links, $this->menuLinks($item['children']));
            } else {
                $links[] = Arr::only($item, ['title', 'uri', 'icon']);
            }
        }

        return $links;
    }
723023
public static function getUrlIdArrByMenuIdArr($menuIdArr)
    {
        $urlIdArr = [];
        foreach ($menuIdArr as $menuId) {
            $link = static::find()
                ->findByMenuId($menuId)
                ->active()
                ->asArray()
                ->all();
            if ($link) {
                foreach ($link as $item) {
                    $urlIdArr[] = $item['url_id'];
                }
            }
        }

        return array_unique($urlIdArr);
    }
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;
	}
481704
public function getMenuItems($menu) {
		if( !isset(self::$menusConf) ) {
			self::$menusConf = IniConfig::build('menus', true);
		}
		if( empty(self::$menusConf) || empty(self::$menusConf->$menu) ) {
			return array();
		}
		return self::$menusConf->$menu;
	}
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;
    }
62304
public static function activeMenu($menu = null)
    {
        if ($menu === null) {
            $activeMenu = self::$_activeMenu;
        } else {
            $activeMenu = $menu;
        }

        if (!array_key_exists($activeMenu, self::$_items)) {
            self::$_items[$activeMenu] = [];
        }

        self::$_activeMenu = $activeMenu;
        return $activeMenu;
    }
833273
public static function getCustomMenuItems($user)
    {
        $menuItems = [];

        if (array_key_exists('menu', config('laralum'))) {
            foreach (config('laralum.menu') as $custom_menu) {
                $pm = new self();
                $pm->name(ucfirst($custom_menu['title']));
                $pm->items = array_merge($pm->items, static::getPackageMenuItems($custom_menu, $user));

                if (count($pm->items) > 0) {
                    array_push($menuItems, $pm);
                }
            }
        }

        return $menuItems;
    }
249582
protected function reorderMenu(ItemInterface $menu)
    {
        $order = [];
        foreach ($menu->getChildren() as $label => $item) {
            $order[$label] = $item->getExtra('position');
        }
        asort($order);
        $menu->reorderChildren(array_keys($order));

        return $menu;
    }
788204
protected function getFiles(): array
    {
        $path = $this->getPath();

        $files = $this->file->allFiles($path);

        if (! $files) {
            throw new MenuFilesNotFound("Menu files have not been found in [{$path}].");
        }

        return $files;
    }
686953
protected function getMenuByName(string $name, $context = null): MenuInterface
    {
        // validate menu name
        $this->validateName($name);

        // get menu
        $menuEntity = null;
        try {
            $menuEntity = $this->Menus
                ->find('all')
                ->where(['name' => $name])
                ->firstOrFail();
            if (!($menuEntity instanceof EntityInterface)) {
                throw new RuntimeException(sprintf(
                    'Expected value of type "Cake\Datasource\EntityInterface", got "%s" instead',
                    gettype($menuEntity)
                ));
            }

            $menuInstance = $menuEntity->get('default') ?
                $this->getMenuItemsFromEvent($name, [], $context) :
                $this->getMenuItemsFromTable($menuEntity);
        } catch (RecordNotFoundException $e) {
            $menuInstance = static::getMenuItemsFromEvent($name, [], $context);
        }

        // maintain backwards compatibility for menu arrays
        if (is_array($menuInstance)) {
            $menuInstance = self::normaliseItems($menuInstance);
            if ($menuEntity instanceof EntityInterface && $menuEntity->get('default')) {
                $menuInstance = $this->sortItems($menuInstance);
            }

            $menuInstance = self::createMenu($menuInstance);
        }

        return $menuInstance;
    }