PHP code example of brainbits / blocking
1. Go to this page and download the library: Download brainbits/blocking 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/ */
brainbits / blocking example snippets
use Brainbits\Blocking\Blocker;
use Brainbits\Blocking\Identity\Identity;
use Brainbits\Blocking\Owner\SymfonySessionOwnerFactory;
use Brainbits\Blocking\Storage\FilesystemStorage;
use Brainbits\Blocking\Validator\ExpiredValidator;
$storage = new FilesystemStorage('/where/to/store/blocks' /* path to directory on filesystem */);
$ownerFactory = new SymfonySessionOwnerFactory($session /* symfony session */);
$validator = new ExpiredValidator(300 /* block will expire after 300 seconds */);
$blocker = new Blocker($storage, $ownerFactory, $validator);
$identity = new Identity('my_content_123');
$block = $blocker->block($identity);
$result = $blocker->unblock($identity);
$result = $blocker->isBlocked($identity);
$block = $blocker->getBlock($identity);