valantir/forumbundle

论坛

安装: 121

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 1

类型:symfony-bundle

1.4.2 2016-05-17 15:55 UTC

This package is not auto-updated.

Last update: 2024-09-22 07:36:35 UTC


README

安装

步骤 1

要将此包安装到您的项目中,请将以下行添加到您的 composer.json 文件中

// composer.json
{
    // ...
    "require": {
        // ...
        "valantir/forumbundle": "dev-master",
    }
}

注意:请用最新的稳定版本替换 dev-master,例如 1.0.0。

然后运行更新命令来安装包

// composer.json
$ php composer.phar update valantir/forumbundle

现在您需要将包添加到您的 AppKernel.php 文件中

<?php
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Valantir\ForumBundle\ValantirForumBundle(),
    // ...
);

步骤 2 - 配置

现在在 routing.yml 文件中添加以下代码

// routing.yml
valantir_forum:
    resource: "@ValantirForumBundle/Resources/config/routing/all.xml"

在您的 config.yml 文件中添加 User 类的路径,并注释掉 assetic.bundles 选项或添加 ValantirForumBundle 到此配置中

//config.yml
valantir_forum: 
    user_class: path/to/user/class
//config.yml
assetic:
    #bundles: []

或者

//config.yml
assetic:
    bundles: [ValantirForumBundle]

ValantirForumBundle 需要 doctrine-extension-bundle,因此请进行配置。例如

// config.yml
stof_doctrine_extensions:
    default_locale: pl_PL
    orm:
        default:
            softdeleteable: true
            sluggable: true
            sortable: true
            tree: true
services:
    gedmo.listener.softdeleteable:
        class: Gedmo\SoftDeleteable\SoftDeleteableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ @annotation_reader ] ]
doctrine:
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        filters:
            softdeleteable:
                class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                enabled: true

ValantirForumBundle 需要 tree, softdeleteable, sortable 和 sluggable

更多关于 doctrine-extension-bundle 的信息

您的用户类需要实现 Valantir\ForumBundle\Entity\UserInterface 或继承 Valantir\ForumBundle\Entity\User

例如

如果您使用 FOSUserBundle 并且您的类扩展了此包的用户类,您可以复制 Valantir\ForumBundle\Entity\User 类中的所有属性和方法。

如果要让用户能够编辑论坛,给他分配 ROLE_FORUM_ADMIN 角色。

步骤 3 - 额外配置

默认情况下,论坛使用 golonka/bbcodeparser (bb_code_golonka_parser 服务),但如果您想使用 php_bbcode 扩展,您必须从 这里 安装它

并添加解析服务

// config.yml
valantir_forum: 
    parser: bb_code_extension_parser

如果您想编写自己的解析器,您可以这样做

  • 创建一个 bbcode 解析器作为服务
  • 扩展 AbstractParser 类 (Valantir\ForumBundle\Service\AbstractParser)
  • 更改配置
// config.yml
valantir_forum: 
    parser: your_bb_code_parser_service