adespresso/white-label-bundle

Symfony2 插件,用于管理白标

安装次数: 87,341

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 23

分支: 0

开放问题: 0

类型:symfony-bundle

2.1.0 2019-09-06 11:53 UTC

This package is not auto-updated.

Last update: 2024-09-21 11:16:25 UTC


README

此插件允许发布网站的白色标签版本。

安装

php composer.phar require adespresso/white-label-bundle

在 Symfony2 中注册此插件

<?php
// AppKernel.php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Ae\WhiteLabelBundle\AeWhiteLabelBundle(),

        );
        ...
    }
}

配置

以下配置参数是针对具有两个不同白标的网站的示例,一个由不同的域名识别,另一个由用户实体中的参数识别。

ae_white_label:
    default_website: foo_site
    websites:
        foo_site:
            label: foo labels
            host: foo.domain.com
            method: byHost
            custom_params:
                customFoo: bar
            priority: 1
        bar_site:
            label: bar labels
            user_param:
                key: origin
                value: bar_website
            method: byUserParam
            priority: 2

Twig

此插件暴露不同的 twig 函数:whitelabel、website 和 impersonateUrl。

白标

基于网站的条件语句(如示例中的 foo_site 和 bar_site)。它允许使用逻辑运算符(如 AND 和 OR)连接条件。

 {% whitelabel 'foo_site' %}
     <a href="#">Home for Foo site</a>
 {% else %}
     <a href="#">Home for Other sites</a>
 {% endwhitelabel %}

网站

返回配置中设置的网站信息。

{% set thisWebsite = website() %}

ImpersonateUrl

为特定的白标网站构建模仿 URL。第一个参数是白标网站,第二个参数(可选)是模仿 URL 需要指向的 URL。

{% set impersonateUrl = impersonateUrl('foo_site', 'http://domain.com' ) %}

版权

© 2017 AdEspresso, Inc

许可证

Apache 2.0(见 LICENSE 文件或 https://apache.ac.cn/licenses/LICENSE-2.0