From: Raphaƫl Gertz Date: Thu, 12 Aug 2021 12:25:07 +0000 (+0200) Subject: Update doc X-Git-Tag: 0.2.0~46 X-Git-Url: https://git.rapsys.eu/userbundle/commitdiff_plain/fb368fd997affe677b6dfb8d9672974726c29716 Update doc --- diff --git a/README.md b/README.md index dc14527..7867c59 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,32 @@ Add bundle custom repository to your project's `composer.json` file: { ..., "repositories": [ - { - "type": "package", - "package": { - "name": "rapsys/userbundle", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://git.rapsys.eu/userbundle", - "reference": "master" - }, - "autoload": { - "psr-4": { - "Rapsys\\UserBundle\\": "" - } - } - } - } + { + "type": "package", + "package": { + "name": "rapsys/userbundle", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://git.rapsys.eu/userbundle", + "reference": "master" + }, + "autoload": { + "psr-4": { + "Rapsys\\UserBundle\\": "" + } + }, + "require": { + "doctrine/doctrine-bundle": "^1.12", + "rapsys/packbundle": "dev-master", + "symfony/flex": "^1.5", + "symfony/form": "^4.4", + "symfony/framework-bundle": "^4.4", + "symfony/security-bundle": "^4.4", + "symfony/validator": "^4.4" + } + } + } ], ... } @@ -79,3 +88,165 @@ class AppKernel extends Kernel // ... } ``` + +### Step 3: Configure the Bundle + +Setup configuration file `config/packages/rapsys_user.yaml` with the following +content available in `Rapsys/UserBundle/Resources/config/packages/rapsys_user.yaml`: + +```yaml +#Doctrine configuration +doctrine: + #Orm configuration + orm: + #Force resolution of UserBundle entities to CustomBundle one + #XXX: without these lines, relations are lookup in parent namespace ignoring CustomBundle extension + resolve_target_entities: + Rapsys\UserBundle\Entity\Group: 'CustomBundle\Entity\Group' + Rapsys\UserBundle\Entity\Civility: 'CustomBundle\Entity\Civility' + Rapsys\UserBundle\Entity\User: 'CustomBundle\Entity\User' + +#RapsysUser configuration +rapsys_user: + #Class replacement + class: + group: 'CustomBundle\Entity\Group' + civility: 'CustomBundle\Entity\Civility' + user: 'CustomBundle\Entity\User' + #Default replacement + default: + group: [ 'User' ] + civility: 'Mister' + #Route replacement + route: + index: + name: 'custom_index' + +#Service configuration +services: + #Register security context service + rapsys_user.access_decision_manager: + class: 'Symfony\Component\Security\Core\Authorization\AccessDecisionManager' + public: true + arguments: [ [ '@security.access.role_hierarchy_voter' ] ] + #Register default controller + Rapsys\UserBundle\Controller\DefaultController: + arguments: [ '@service_container', '@router', '@translator' ] + autowire: true + tags: [ 'controller.service_arguments' ] + #Register Authentication success handler + security.authentication.success_handler: + class: 'Rapsys\UserBundle\Handler\AuthenticationSuccessHandler' + arguments: [ '@router', {} ] + #Register Authentication failure handler + security.authentication.failure_handler: + class: 'Rapsys\UserBundle\Handler\AuthenticationFailureHandler' + arguments: [ '@http_kernel', '@security.http_utils', {}, '@logger', '@service_container', '@router', '@rapsys_pack.slugger_util'] + #Register logout success handler + security.logout.success_handler: + class: 'Rapsys\UserBundle\Handler\LogoutSuccessHandler' + arguments: [ '@service_container', '/', '@router' ] + #Register security user checker + security.user_checker: + class: 'Rapsys\UserBundle\Checker\UserChecker' +``` + +Open a command console, enter your project directory and execute the following +command to see default bundle configuration: + +```console +$ php bin/console config:dump-reference RapsysUserBundle +``` + +Open a command console, enter your project directory and execute the following +command to see current bundle configuration: + +```console +$ php bin/console debug:config RapsysUserBundle +``` + +### Step 4: Setup custom bundle entities + +Setup configuration file `CustomBundle/Resources/config/doctrine/User.orm.yml` with the +following content: + +```yaml +CustomBundle\Entity\User: + type: entity + #repositoryClass: CustomBundle\Repository\UserRepository + table: users + associationOverride: + groups: + joinTable: + name: users_groups + joinColumns: + id: + name: user_id + inverseJoinColumns: + id: + name: group_id +``` + +Setup configuration file `Resources/config/doctrine/Group.orm.yml` with the +following content: + +```yaml +CustomBundle\Entity\Group: + type: entity + #repositoryClass: CustomBundle\Repository\GroupRepository + table: groups + manyToMany: + users: + targetEntity: Rapsys\AirBundle\Entity\User + mappedBy: groups +``` + +Setup configuration file `Resources/config/doctrine/Civility.orm.yml` with the +following content: + +```yaml +CustomBundle\Entity\Civility: + type: entity + #repositoryClass: CustomBundle\Repository\CivilityRepository + table: civilities + oneToMany: + users: + targetEntity: User + mappedBy: civility +``` + +Setup entity file `CustomBundle/Entity/User.php` with the following content: + +```php +