定制 avris/micrus-js 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

avris/micrus-js

最新稳定版本:v3.0.1

Composer 安装命令:

composer require avris/micrus-js

包简介

JavaScript plugin for Micrus framework (handles routing and localization)

README 文档

README

This is a module for Micrus framework that allows you to generate asset URLs, route URLs and localized strings from client-side JavaScript code.

To install this module, open the file app/Config/modules.yml and add:

 - Avris\Micrus\MicrusJs\MicrusJsModule

Then run:

composer require avris/micrus-js

Then add this code to your main layout:

<script src="{{ route('micrusjs') }}"></script>

Sample

Available methods correspond to their PHP version.

console.log(M.user);
console.log(M.isGranted('ROLE_ADMIN'));
console.log(M.routeExists('routeName'));
console.log(M.route('routeName', {id: 15}));
console.log(M.locale);
console.log(M.l('localized.string', {foo: "bar"}));
console.log(M.asset('image.png'));

Extending

If you want to pass some dynamic data to JavaScript, say, the name of a current route, you can do it by defining a service with tag jsVars that implements Avris\Micrus\MicrusJs\JsVarsInterface:

To define a JS version of a localizator selector (see: Localizator Module) make it implement Avris\Micrus\MicrusJs\JsFunctionInterface.

Copyright

统计信息

  • 总下载量: 247
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-25