Skip to content
No description or website provided.
Find file
Latest commit 170577d @kriswallsmith kriswallsmith added composer.json
Failed to load latest commit information.
Form/DataTransformer fixed use statement
Resources/config fixed class name
OpenSkyHtmLawedBundle.php fixed extension alias
phpunit.xml.dist Create HtmLawed service and DI extension for configuration


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.


Submodule Creation

Add HtmLawedBundle to your src/ directory:

$ git submodule add 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

    'OpenSky' => __DIR__,

Application Kernel

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

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


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

    file: %kernel.root_dir%/../vendor/htmlawed/htmLawed.php
                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:


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.