PHP code example of bukashk0zzz / filter-bundle

1. Go to this page and download the library: Download bukashk0zzz/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/ */

    

bukashk0zzz / filter-bundle example snippets


$bundles = array(
	// ... other bundles
	new Bukashk0zzz\FilterBundle\Bukashk0zzzFilterBundle(),
);

use Bukashk0zzz\FilterBundle\Annotation\FilterAnnotation as Filter;


namespace AppBundle\Entity;

use Bukashk0zzz\FilterBundle\Annotation\FilterAnnotation as Filter;

/**
 * User Entity
 */
class User
{
    #[Filter(parameters: [
        'filter' => 'StripTags',
        'options' => ['allowTags' => 'br']
    ])]
    #[Filter(parameters: ['filter' => 'StringTrim'])]
    #[Filter(parameters: ['filter' => 'StripNewlines'])]
    protected $name;

    #[Filter(parameters: ['filter' => 'StripTags'])]
    #[Filter(parameters: ['filter' => 'StringTrim'])]
    #[Filter(parameters: ['filter' => 'AppBundle\Filter\MyCustomFilter'])]
    protected $about;
}


public function indexAction()
{

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

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

    return ['entity' => $entity];
}