netinfluence/secure-display-bundle

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

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

2.1.0 2019-03-19 10:11 UTC

This package is auto-updated.

Last update: 2022-02-01 12:46:30 UTC


README

NetinfluenceSecureDisplayBundle 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 knpbundles.com Build Status

Requirements

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

Version 1.x is compatible with Symfony 2 (2.3 - 2.8), version 2.x are compatible with Symfony 2.8, 3.x and 4.x
Code is tested on PHP 5.6 and PHP 7.0 to PHP 7.3

Installation

Step 1: Composer

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

{
   "require": {
        "netinfluence/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 Netinfluence\SecureDisplayBundle\NetinfluenceSecureDisplayBundle()
        );

        return $bundles;
    }
}

Step 3: Config

Define the configuration of the bundle into the config file

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

Step 4: Routing

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

# app/config/routing.yml
netinfluence_secure_display:
    resource: "@NetinfluenceSecureDisplayBundle/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/netinfluencesecuredisplay/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.