tamago / tips-manager-bundle
显示提示的简单包
dev-master
2016-05-04 22:13 UTC
Requires
- php: >=5.3.9
- doctrine/orm: ^2.5.2
- lexik/translation-bundle: ^4.0
- symfony/symfony: ^2.8
This package is not auto-updated.
Last update: 2024-09-14 17:59:01 UTC
README
此Symfony包允许您将提示管理器集成到您的Symfony应用程序中。提示管理器会显示与您的应用程序相关的提示。提示可以用不同的语言显示。
想法是
- 在文件(yml)中编写提示及其翻译,至少包含一种语言(例如,您网站的默认语言)。
- 使用命令行将提示及其翻译加载到数据库中。
- 通过编辑页面自由编辑/添加翻译。
您还可以通过点赞/踩按钮对提示提供反馈。反馈和其他与提示相关的详细信息可以在统计页面上查看。
以下是示例提示的截图
安装
将包添加到您的composer.json
文件中
require: { // ... "tamago/tips-manager-bundle": "dev-master" }
或直接通过composer安装:
# Latest stable
composer require tamago/tips-manager-bundle dev-master
然后运行composer update
composer update
# OR
composer update tamago/tips-manager-bundle # to only update the bundle
TamagoTipManagerBundle还会安装LexikTranslationManagerBundle,它用作存储和编辑已翻译提示的机制。确保这两个包都已注册到您的内核中
// in AppKernel::registerBundles() $bundles = array( // ... new Tamago\TipsManagerBundle\TamagoTipsManagerBundle(), new Lexik\Bundle\TranslationBundle\LexikTranslationBundle(), //if you don't have this installed already // ... );
集成
⚠️尽管LexikTranslationManagerBundle支持Doctrine存储类型,但TamagoTipManagerBundle目前仅正式支持Doctrine ORM。
创建数据库模式
php app/console doctrine:database:create php app/console doctrine:schema:update
在您想要显示提示的页面上渲染
{{ render(controller('TamagoTipsManagerBundle:TipsManager:index', {'domain': 'some-domain-name', 'identifier': 'my-identifier'})) }}
上述“domain”和“identifier”属性值应分别为提示所属的域和标识符的自定义名称。您可以将提示分为多个类别/域。
配置
最小配置
如果您已经使用LexikTranslationBundle,则可以跳过此步骤。
您必须至少定义一个后备区域。
lexik_translation: fallback_locale: [<locale>] managed_locales: [ <locale1>, <local2>, ... ] storage: type: orm object_manager: <entity/object manager name>
导入翻译
要将翻译文件内容导入数据库,请将提示翻译YAML文件放在您的项目中的某个位置,并从该目录导入。例如
php app/console lexik:translations:import -p app/Resources/translations/tips/
有关简单翻译文件的示例,请参阅tips-example.en.yml
路由
要使用基于tamago的管理页面,请将以下内容添加到应用程序的路由文件中
# app/config/routing.yml tip_bundle_homepage: resource: "@TamagoTipsManagerBundle/Resources/config/routing.yml" prefix: /_tips
统计页面将在此处提供
/_tips/stats
编辑/添加提示的页面将在此处提供
/_tips/editor