gfilipiak/cookie-bundle

此组件提供Cookie声明层

安装: 43

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 2

公开问题: 0

类型:symfony-bundle

dev-master 2014-02-01 19:45 UTC

This package is not auto-updated.

Last update: 2024-09-24 06:01:17 UTC


README

#ConWeb.pl Cookie Bundle

此组件提供具有可定制模板的简单Cookie声明层。

安装

安装此组件可以通过以下简单步骤完成

  1. 将组件添加到项目的composer依赖中
// composer.json
{
    // ...
    require: {
        // ...
        "gfilipiak/cookie-bundle": "dev-master"
    }
}
  1. 更新您的composer安装
composer update
  1. 将组件添加到您的应用程序内核中
// application/ApplicationKernel.php
public function registerBundles()
{
	// ...
	$bundle = array(
		// ...
        new ConWeb\Bundle\CookieBundle\CookieBundle(),
	);
    // ...

    return $bundles;
}
  1. 将路由导入添加到您的routing.yml中
cookie:
    resource: "@CookieBundle/Resources/config/routing.xml"
    prefix:   /

自定义

您可以通过在config.yml文件中放置配置参数来更改默认的声明模板

cookie:
        template: AcmeBundle:Cookie:statement.html.twig

模板应具有以下结构

{% if not accepted %}
    {% stylesheets '@CookieBundle/Resources/public/less/style.less' %}
    <link rel="stylesheet" href="{{ asset_url }}">
    {% endstylesheets %}

    <section class="cookie">
        Your statement here.

     <section class="agree-button">
                <button id="cookieAgree" class="btn-success btn-small" data-ajax-url="{{ path('cookie_accept') }}">
                    Akceptuję
                </button>
            </section>
        </section>
        {% javascripts '@CookieBundle/Resources/public/js/script.js' %}
        <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
    {% endif %}

待办事项

  • 仅自定义声明文本,而不是整个模板
  • 自定义路径较少