Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com.
Auto register some common services
composer require knplabs/rad-auto-registration:~2.0
class AppKernel
{
function registerBundles()
{
$bundles = array(
//...
new Knp\Rad\AutoRegistration\Bundle\AutoRegistrationBundle($this), // !! Do not forget to inject the kernel !!
//...
);
//...
return $bundles;
}
}
Just activate doctrine
(or doctrine_mongodb
ou doctrine_couchdb
depending on your needs) into your configuration.
knp_rad_auto_registration:
enable:
doctrine: ~
doctrine_mongodb: ~
doctrine_couchdb: ~
Now all repositories are auto-registred.
Entity | Repository |
---|---|
MyProjectBundle\Entity\User | my_project_bundle.entity.user_repository |
TheOtherBundle\Entity\Model\Address | the_other_bundle.model.user.address_repository |
MyProjectBunde\Document\User | my_project_bundle.document.user_repository |
Your doctrine entity (or documents) should be stored under Entity
, Document
or Model
sub-namespace.
Just activate constraint_validator
into your configuration.
knp_rad_auto_registration:
enable:
constraint_validator: ~
Now all custom constaint validators are auto-registered.
Your constraint validators should be stored under Validation
or Validator
sub-namespace.
Just activate form_type_extension
into your configuration.
knp_rad_auto_registration:
enable:
form_type_extension: ~
Now all form type extensions are auto-registred.
Your form type extensions should be stored under Form
sub-namespace.
Just activate security_voter
into your configuration.
knp_rad_auto_registration:
enable:
security_voter: ~
Now all the voters are auto-registered.
Your security voters should be stored under Security
sub-namespace.
Just activate twig_extension
into your configuration.
knp_rad_auto_registration:
enable:
twig_extension: ~
Now all Twig extensions are auto-registered.
Your Twig extensions should be stored under Twig
or Templating
sub-namespace.
By default, all autoregistered services are marked as private
(public: false
). You can overide this behavior by setting the public
parameter to true
.
Example:
knp_rad_auto_registration:
enable:
doctrine:
public: true
doctrine_mongodb:
public: false
doctrine_couchdb:
public: false
You can apply auto-registration on only certains bundle. You just have to add a bundles
configuration:
knp_rad_auto_registration:
enable:
# ...
bundles: [ App, ProductBundle ]
All auto-registered services are set as private
, so it's impossible to get them by using $container->get('service_name')
. If needed, create the service definition by yourself.