2、使用 CProflie
调用
<?php
use fec\helpers\CUrl;
use fec\helpers\CProfile;
class Menu{
public static function getMenuData(){
$obj_data = ["DMenu","Info",'getMenu',true];
$men_arr = CProfile::getInstance()->fetch($obj_data);
return $men_arr;
}
配置:
<?php
public function getModulesConfig(){
return [
'DMenu' => [
'moduleDir' =>'\appdata\code\Blog\DMenu',
'apiurl' =>'http://120.24.37.249:100/dmenu',
'token' =>'xxxxxx',
],
];
}
数据来源:
<?php
namespace appdata\code\Blog\DMenu\o;
use Yii;
class Info
{
public static function getMenu($current_menu=''){
$menuArr = self::getMenuArr();
return json_encode($menuArr );
}
远程:
<?php
namespace appdata\code\Blog\DMenu\controllers;
use Yii;
use fec\controllers\ModulesapiController;
use fec\helpers\CUrl;
class InfoController extends ModulesapiController
{
public $_name_space = __NAMESPACE__;
}