The Blocking Component provides methods to manage content based blocking.
<?phpuseBrainbits\Blocking\Blocker;
useBrainbits\Blocking\Identity\Identity;
useBrainbits\Blocking\Owner\SymfonySessionOwnerFactory;
useBrainbits\Blocking\Storage\FilesystemStorage;
useBrainbits\Blocking\Validator\ExpiredValidator;
$storage = newFilesystemStorage('/where/to/store/blocks'/* path to directory on filesystem */);
$ownerFactory = newSymfonySessionOwnerFactory($session/* symfony session */);
$validator = newExpiredValidator(300/* block will expire after 300 seconds */);
$blocker = newBlocker($storage, $ownerFactory, $validator);
$identity = newIdentity('my_content_123');
$block = $blocker->block($identity);
$result = $blocker->unblock($identity);
$result = $blocker->isBlocked($identity);
$block = $blocker->getBlock($identity);The blocking storage is used to store the block information.
A file based blocking storage is provided. It writes block-files to the filesystem, based on the blocking identifier.
The blocking identity is used to identify the content that is being blocked.
A general purpose blocking identify is provided, that uses a string as an identifier.
The blocking owner is used to identify the user that created the block.
A symfony session based owner class is provided.
The blocking validator is used to test wether or not an existing block is still valid.
A validator that checks a block via last modification time is provided.