waynestate/parse-menu
Composer 安装命令:
composer require waynestate/parse-menu
包简介
Parse menus from the Wayne State University API
README 文档
README
Parse menus from the Wayne State University API
Installation
To install this library, run the command below and you will get the latest version
composer require waynestate/parse-menu
Usage
Create the object
# start.php
use Waynestate\Menuitems\ParseMenu;
...
$parseMenu = new ParseMenu;
Make an API call for the menu
# controller.php
try {
// Pull a specific menu from the API for a site
$params = array(
'site_id' => 1,
'menu_id' => 2,
'ttl' => TTL,
);
$menus = $api->sendRequest('cms.menuitems.listing', $params);
// Menu config
$menu_config = array(
'page_selected' => 1,
);
// Get a final array to display the main menu
$main_menu = $parseMenu->parse($menus[2], $menu_config);
// Get the breadcrumbs from the parsed menu $main_menu
$breadcrumbs = array();
if(count($site_menu['meta']['path']) > 0) {
$breadcrumbs = $parseMenu->getBreadCrumbs($main_menu);
// Add the site root crumb
$root_crumb = [
'display_name' => 'Home',
'relative_url' => '/',
];
$breadcrumbs = $parseMenu->prependBreadCrumb($breadcrumbs, $root_crumb);
}
// Just display the first level in the header
$top_menu_config = array(
'display_levels' => 1,
);
// Parse the existing menu with the specific top_menu config
$top_menu = $parseMenu->parse($main_menu, $top_menu_config);
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage(). "\n";
}
Return values
$main_menu['meta'] = [
'has_selected' => boolean, // default: false
'has_submenu' => boolean, // default: false
'depth' => integer, // default: 0
'path' => array, // default: array()
]
$main_menu['menu'] = [
// Array of the menu
]
$breadcrumbs = [
// Sequential array of individual breadcrumbs in order based on the $main_menu['meta']['path']
]
Config Options
'page_selected' = Page ID for selection path (optional)
'skip_levels' = Number of levels to skip from the root (requires page_selected)
'display_levels' = Number of levels to display from the root (requires page_selected, if > 1)
'full_menu' = Return the full menu regardless if there is a page selected (boolean, default: false)
TODO: 'show_levels' = Number of levels to display from the leaf (requires page_selected)
TODO: 'add_home' = Add 'Home' as the first menu item (this may not be needed)
Exceptions
InvalidDisplayLevelsException = If 'display_levels' > 1 and no 'page_selected' found
Tests
phpunit
Code Coverage
phpunit --coverage-html ./coverage
waynestate/parse-menu 适用场景与选型建议
waynestate/parse-menu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35.37k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「array」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 waynestate/parse-menu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 waynestate/parse-menu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 waynestate/parse-menu 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Trait providing methods to set class properties with an array.
An MT940 bank statement parser for PHP
Traits to build collections of specific objects
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
统计信息
- 总下载量: 35.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-09-12