mb/secure-display-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

MBSecureDisplayBundle is a small simple bundle which protect emails and phone numbers behine encryption and JavaScript

Installs: 219

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.1 2016-07-05 10:33 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:59:37 UTC


README

MBSecureDisplayBundle is a small simple bundle which protect emails, phone numbers and any text you want from spam bot, by using encryption, ajax and JavaScript.

SensioLabsInsight Build Status

Requirements

Before installing this bundle, you need to have a working installation of FOSJsRoutingBundle.

Installation

Step 1: Composer

First you need to add mb/secure-display-bundle to composer.json:

{
   "require": {
        "mb/secure-display-bundle": "dev-master"
    }
}

note: replace dev-master with the last version of this bundle.

Step 2: AppKernel

Register the bundle into the Symfony AppKernel

// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new MB\SecureDisplayBundle\MBSecureDisplayBundle()
        );

        return $bundles;
    }
}

Step 3: Config

Define the configuration of the bundle into the config file

# app/config/config.yml
mb_secure_display:
    # Required, key used to encrypt data
    key: "my_super_random_secure_key"
    # Optional, you can customize used template here
    template: 'MBSecureDisplayBundle::secure_display.html.twig'

Step 4: Routing

Register the routing of the bundle to be able to perform ajax requests

# app/config/routing.yml
mb_secure_display:
    resource: "@MBSecureDisplayBundle/Resources/config/routing.yml"
    prefix:   /

Step 5: Assets

Publish the assets to be able to use the javascript file

$ php app/console assets:install --symlink web

Add this line in your layout:

<script src="{{ asset('bundles/mbsecuredisplay/js/display.js') }}"></script>

Declaration

{{ some.data|secureDisplay(label, action, attributes) }}

parameters

  • label: optional
    • type: string
    • value: text to display if the javascript is not enabled
  • action: optional
    • type: string
    • value: action to append before the link (like "tel:012 345 67" or "mailto:john@doe.com")
  • attributes: optional
    • type: array
    • value: html attributes to add to the text

Usage

<h4>Here are my personal informations</h4>

{# Default usage #}
<p>My name is : {{ contact.name|secureDisplay }}</p>

{# Custom label when JavaScript is not enabled #}
<p>You can find me at : {{ contact.address|secureDisplay('this address is protected') }}</p>

{# Transform phone number into clicable link #}
{# Can be 'tel', 'mailto', whatever you want #}
<p>My phone number is : {{ contact.phoneNumber|secureDisplay(null, 'tel') }}</p>

{# Custom html attributes #}
<p>My favorite color is : {{ contact.color|secureDisplay(null, null, { 'style': 'color: red' }) }}</p>

Of course, you can mix any of these tree parameters as you want.