PHP code example of progmancod / dms-filter-bundle

1. Go to this page and download the library: Download progmancod/dms-filter-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

progmancod / dms-filter-bundle example snippets




namespace App\Entity;

//Import Annotations
use DMS\Filter\Rules as Filter;

class User
{

    /**
    * @Filter\StripTags()
    * @Filter\Trim()
    * @Filter\StripNewlines()
    *
    * @var string
    */
    public $name;

    /**
    * @Filter\StripTags()
    * @Filter\Trim()
    * @Filter\StripNewlines()
    *
    * @var string
    */
    public $email;

}

public function indexAction()
{

    $entity = new \Acme\DemoBundle\Entity\SampleEntity();
    $entity->name = "My <b>name</b>";
    $entity->email = " [email protected]";

    $oldEntity = clone $entity;

    $filterService = $this->get('dms.filter');
    $filterService->filterEntity($entity);

    return array('entity' => $entity, "old" => $oldEntity);
}

class TaskType extends AbstractType
{
    // ...

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
                'cascade_filter' => false,
            ));
    }

    // ...
}



namespace App\Entity;

//Import Annotations
use DMS\Filter\Rules as Filter;

//Import Symfony Rules
use DMS\Bundle\FilterBundle\Rule as SfFilter;

class User
{
    /**
    * @Filter\StripTags()
    * @SfFilter\Service(service="dms.sample", method="filterIt")
    *
    * @var string
    */
    public $name;
}