<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Config; use Illuminate\Support\Str; class MemberMenu { private static $menu = array(); public static function register($hQj_u) { self::$menu[] = $hQj_u; } public static function get() { goto vzsB5; vzsB5: $hQj_u = array(); goto k5Xvk; NBOkO: $hQj_u = self::mergeMenu($hQj_u); goto r8Vam; k5Xvk: foreach (self::$menu as $FSL7c) { if ($FSL7c instanceof \Closure) { $FSL7c = call_user_func($FSL7c); } $hQj_u = array_merge($hQj_u, $FSL7c); } goto NBOkO; r8Vam: return $hQj_u; goto g0zLJ; g0zLJ: } private static function sort() { static $wuamL = 1000; return $wuamL++; } private static function mergeMenu($hQj_u, $w4kK_ = '', $kmcyt = 1, $zBPGV = null) { goto UBK3B; vxQ4_: $hhe9d = array(); goto zQCGm; YAUtv: return $hhe9d; goto az47H; zQCGm: foreach ($hQj_u as $FSL7c) { goto geqT8; ccNnp: if (!isset($hhe9d[$D5qRP])) { $hhe9d[$D5qRP] = $FSL7c; } goto e1NFV; u5lF_: if (1 == $kmcyt) { $D5qRP = $w4kK_ . $FSL7c['title'] . '^' . $FSL7c['icon'] . '^' . $FSL7c['sort']; } else { $D5qRP = $w4kK_ . $FSL7c['title']; } goto SzItY; SzItY: if (isset($FSL7c['icon'])) { if (preg_match('/^[a-zA-Z0-9\\-]+$/', $FSL7c['icon'])) { $FSL7c['icon'] = "<i class='icon iconfont icon-{$FSL7c['icon']}'></i>"; } } goto ccNnp; JJiez: if ($zBPGV) { if (!call_user_func($zBPGV, $FSL7c)) { continue; } } goto UJi7Y; e1NFV: unset($hhe9d[$D5qRP]['children']); goto Szcd9; UJi7Y: if (!isset($FSL7c['sort'])) { $FSL7c['sort'] = self::sort(); } goto u5lF_; Szcd9: if (!empty($FSL7c['children'])) { $hhe9d = array_merge($hhe9d, self::mergeMenu($FSL7c['children'], $D5qRP . '^^', $kmcyt + 1, $zBPGV)); } goto eZ_jx; geqT8: if (empty($FSL7c)) { continue; } goto JJiez; eZ_jx: } goto F3fw8; UBK3B: if (empty($hQj_u)) { return array(); } goto vxQ4_; F3fw8: if ($kmcyt == 1) { uasort($hhe9d, function ($E1Tkt, $TCxPq) { return $E1Tkt['sort'] - $TCxPq['sort']; }); return self::mergeMenuTree($hhe9d); } goto YAUtv; az47H: } private static function mergeMenuTree($bLbA0, $w4kK_ = '') { goto SmFd1; unRDO: foreach ($bLbA0 as $D5qRP => $qGgGl) { goto yFJKK; Y22yx: if (empty($FSL7c['children'])) { unset($FSL7c['children']); } goto QhZHO; yFJKK: if ($D5qRP === $w4kK_) { continue; } goto ILNpO; ILNpO: $G2Rc8 = explode('^^', $D5qRP); goto p_Oc8; p_Oc8: if ($w4kK_) { if (!Str::startsWith($D5qRP, $w4kK_)) { continue; } if (count(explode('^^', $w4kK_)) !== count(explode('^^', $D5qRP))) { continue; } } else { if (1 != count($G2Rc8)) { continue; } } goto FYUIp; QhZHO: if (empty($FSL7c['children']) && empty($FSL7c['url'])) { continue; } goto MJoKw; fgrSJ: $FSL7c['children'] = self::mergeMenuTree($bLbA0, $D5qRP . '^^'); goto Y22yx; FYUIp: $FSL7c = $qGgGl; goto fgrSJ; MJoKw: $JtE8_[] = $FSL7c; goto CpjMh; CpjMh: } goto MxnDV; SmFd1: $JtE8_ = array(); goto unRDO; MxnDV: return $JtE8_; goto q7sMy; q7sMy: } }