Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 DependencyInjection
Octocat-spinner-32 Form
Octocat-spinner-32 Resources
Octocat-spinner-32 Tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 OpenSkyHtmLawedBundle.php
Octocat-spinner-32 README.md
Octocat-spinner-32 composer.json
Octocat-spinner-32 phpunit.xml.dist
README.md

HtmLawedBundle

This bundle integrates htmLawed with Symfony2. It allows you to define htmLawed configuration profiles, which are exposed as services implementing ValueTransformerInterface. These transformers can easily be attached to form fields for input sanitization.

Installation

Submodule Creation

Add HtmLawedBundle to your src/ directory:

$ git submodule add git://github.com/opensky/HtmLawedBundle.git src/OpenSky/Bundle/HtmLawedBundle

Class Autoloading

If the src/ directory is already configured in your project's autoload.php via registerNamespaceFallback(), no changes should be necessary. Otherwise, either define the fallback directory or explicitly add the "OpenSky" namespace:

# src/autoload.php

$loader->registerNamespaces(array(
    'OpenSky' => __DIR__,
));

Application Kernel

Add HtmLawedBundle to the registerBundles() method of your application kernel:

public function registerBundles()
{
    return array(
        new OpenSky\Bundle\HtmLawedBundle\OpenSkyHtmLawedBundle(),
    );
}

Configuration

This bundle defines an HtmLawed service, which is constructed with $config and $spec parameters. It implements a single process() method that filters a string value through the htmLawed() function. The $config and $spec parameters provided during construction will be passed to htmLawed().

HtmLawed Extension

HtmLawedBundle may be configured with the following:

# app/config/config.yml

opensky_htmlawed:
    file: %kernel.root_dir%/../vendor/htmlawed/htmLawed.php
    profiles:
        custom:
            config:
                comment: 0
                cdata:   1
            spec: a=title
        default: ~

The above example would define two services: htmlawed.custom and htmlawed.default, which will use their respective options as additional arguments to htmLawed() when filtering input.

The file option should be set with the path to the htmLawed vendor library. The service container will ensure this file resource is loaded before one of the configured services is constructed.

See also:

HtmLawedTransformer

The services created by this bundle implement DataTransformerInterface from the Symfony2 Form component. Filtering is only done via reverseTransform(). The transform() method is an identity function (i.e. it returns its input).

Using with Form Fields

The htmLawed services should be assigned to form fields as a client transformer. Documentation is forthcoming.

Something went wrong with that request. Please try again.