brainbits / blocking
Object blocking
Installs: 28 332
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 4
Open Issues: 2
Requires
- php: ^8.2
- psr/clock: ^1.0
Requires (Dev)
- brainbits/phpcs-standard: ^7.0.1
- brainbits/phpstan-rules: ^3.1
- matthiasnoback/symfony-config-test: ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^5.1
- mikey179/vfsstream: ^1.6.11
- phpstan/phpstan: ^1.10.67
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-symfony: ^1.3
- phpunit/phpunit: ^10.5
- predis/predis: ^2.2
- symfony/clock: ^6.4|^7.0
- symfony/config: ^6.4|^7.0
- symfony/dependency-injection: ^6.4|^7.0
- symfony/http-foundation: ^6.4|^7.0
- symfony/http-kernel: ^6.4|^7.0
- symfony/routing: ^6.4|^7.0
- symfony/security-core: ^6.4|^7.0
Suggests
- predis/predis: If you want to use the PredisStorage
- symfony/http-foundation: If you want to use the SymfonySessionOwnerFactory
- symfony/security-core: If you want to use the SymfonyTokenOwnerFactory
Conflicts
- phpspec/prophecy: 1.12.*
README
The Blocking Component provides methods to manage content based blocking.
<?php 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);
Blocking Storage
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.
Blocking Identity
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.
Blocking Owner
The blocking owner is used to identify the user that created the block.
A symfony session based owner class is provided.
Blocking Validator
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.