alister/reserved-names-bundle
A bundled service to clean, and check, a given username against an (extensible) list of reserved words/usernames.
Note: This DOES NOT validate usernames. That should happen (and potentially disallow names) before getting to this stage.
Add to app/AppKernel.php
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
// ... many others
new Alister\ReservedNamesBundle\AlisterReservedNamesBundle(),
);
Add to app/config/config.yml
alister_reserved_names:
names:
# These keys will be lower-cased
- myname
- myothername
- alister
- private
Use
$username = 'myname_123';
$reserved = $this->container->get('alister_reserved_names.check');
if ($reserved->isReserved($username)) {
echo "{$username} is reserved";
}
Services provided:
Testing is done with the classes directly, and also via a container, to test the service initialisation. This also allows a check for the 'local reservations' - extra names that can be defined in the local application. The container-based test includes a micro-application to build the container, and so run the full test. How to create a test setup for a local test of the service.
Make a validator (from existing code) and put into this bundle, with tests and examples See: http://stackoverflow.com/questions/7004601/symfony2-testing-entity-validation-constraints
How can I help you explore Laravel packages today?