seosa/feedback-bundle

此包已被放弃,不再维护。未建议替代包。

此Bundle为Symfony2应用提供反馈功能

安装: 236

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 1

开放问题: 0

类型:symfony-bundle

dev-master 2014-12-19 11:50 UTC

This package is not auto-updated.

Last update: 2017-09-26 10:37:40 UTC


README

特性

  • 提供反馈界面

安装

步骤 1:使用Composer下载SeoSAFeedbackBundle

在您的composer.json中添加SeoSAFeedbackBundle

{
    "require": {
        "seosa/feedback-bundle": "dev-master"
    }
}

现在运行以下命令让Composer下载该包

$ php composer.phar update seosa/feedback-bundle

Composer会将包安装到您的项目的seosa/feedback-bundle目录下。

步骤 2:启用Bundle

在Kernel中启用Bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FOS\RestBundle\FOSRestBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle($this),
        new SeoSA\FeedbackBundle\SeoSAFeedbackBundle(),
        // ...
    );
}

步骤 3:创建您自己的消息类

匿名

// src/Acme/FeedbackBundle/Entity/FeedbackMessage.php
namespace Acme\FeedbackBundle\Entity;

**
 * Class Acme\FeedbackBundle\Entity\FeedbackMessage
 *
 * @ORM\Entity
 */
class FeedbackMessage extends Message
{
}

或签名

// src/Acme/FeedbackBundle/Entity/FeedbackMessage.php
namespace Acme\FeedbackBundle\Entity;

use Symfony\Component\Security\Core\User\UserInterface;

**
 * Class Acme\FeedbackBundle\Entity\FeedbackMessage
 *
 * @ORM\Entity
 */
class FeedbackMessage extends Message implements SignedMessageInterface
{
    /**
     * @var User
     * @ORM\ManyToOne(targetEntity="Acme\FeedbackBundle\EntityUser", cascade={"remove"})
     */
    protected $author;

    /**
     * @param UserInterface|null $user
     *
     * @return $this
     */
    public function setAuthor(UserInterface $user = null)
    {
        $this->author = $user;

        return $this;
    }

    /**
     * @return UserInterface|null
     */
    public function getAuthor()
    {
        return $this->author;
    }
}

步骤 4:导入SeoSAFeedbackBundle路由

在YAML中类似以下内容

# app/config/routing.yml

seo_sa_feedback:
    type: rest
    resource: @SeoSAFeedbackBundle/Resources/config/routing.yml
    prefix: /feedback
    defaults: {_format: 'html'}

步骤 5:添加最小配置

# app/config/config.yml

seo_sa_feedback:
    message:
        class: Acme\FeedbackBundle\Entity\FeedbackMessage

步骤 6:将Bundle添加到Assetic

# app/config/config.yml

assetic:
    ....
    bundles: ['SeoSAFeedbackBundle']

最后一步:将按钮或面板添加到您的模板中

{# Add a button #}

{% include 'SeoSAFeedbackBundle:Feedback:button.html.twig' %}
{# Add a panel #}

{% include 'SeoSAFeedbackBundle:Feedback:panel.html.twig' %}

可选

覆盖模板

# app/config/config.yml

seo_sa_feedback:
    ....
    templating:
        layout:               'AcmeFeedbackBundle::feedback-layout.html.twig'
        message_show:         'AcmeFeedbackBundle:FeedbackMessage:show.html.twig'
        message_form:         'AcmeFeedbackBundle:FeedbackMessage:form.html.twig'
        message_list:         'AcmeFeedbackBundle:FeedbackMessage:list.html.twig'

启用SonataAdminIntegration

# app/config/config.yml

seo_sa_feedback:
    ....
    sonata_admin:
        enabled:              true
        group:                YouSonataAdminGroup
        label:                YouSonataAdminTitle