kookas/movetobundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kookas/movetobundle

Composer 安装命令:

composer require kookas/movetobundle

包简介

Generate paths without having to restate every parameter in the current one.

README 文档

README

MoveToBundle for Symfony and Twig lets you generate paths to routes by copying all the parameters of the current route and applying them to another route with the option of modifying all or only some of those parameters. No more extremely long path() calls!

To install, use composer require kookas/movetobundle and then insert the line new Kookas\MoveToBundle\KookasMoveToBundle() into your AppKernel.php file. Alternatively, you can simply download the bundle straight from the repository and use that.

To use, call the Twig function moveTo(params, route = null). This will generate a path from the current route parameters combined with the parameters provided in the first argument, with your parameters taking precedence where conflicts arise. By default, the route used is the current route, but you can specify a different one by name in the second argument.

For example, suppose I have a blog system that lets any user set up a blog and make blog posts, which can then have paginated comments. The URI for the comments of a blog post might look like this:

/blogs/myblog/top-10-healthy-foods-in-existence/comments/page-1

If I want to make a button to go to page-2, not only would I normally have to specify the current route again, but I'd also have to respecify both the blog name and the post slug in path(). With MoveToBundle, you can just do this:

{{ moveTo({'page':2}) }}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-13