1. Go to this page and download the library: Download hottomali/profanity-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/ */
hottomali / profanity-bundle example snippets
$check = $this->get('vangrg_profanity.checker');
$hasProfanity = $check->hasProfanity($badWords);
$cleanWords = $check->obfuscateIfProfane($badWords);
/* customized word list from array */
$badWords = array('bad', 'words');
/* or load from db */
$badWords = $this->getDoctrine()->getManagerForClass(Profanity::class)
->getRepository(Profanity::class)
->getProfanitiesArray();
$this->get('vangrg_profanity.storage')->setProfanities($badWords);
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vangrg\ProfanityBundle\Validator\Constraints as ProfanityAssert;
/**
* Post
*
* @ORM\Table(name="post")
* @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")
*/
class Post
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @Assert\Length(min=8, max=64)
* @ProfanityAssert\ProfanityCheck
* @ORM\Column(name="title", type="string", length=64)
*/
private $title;
}
php composer.phar
php bin/console vangrg:profanities:populate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.