]> Raphaël G. Git Repositories - userbundle/commitdiff
Update doc
authorRaphaël Gertz <git@rapsys.eu>
Thu, 12 Aug 2021 12:25:07 +0000 (14:25 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Thu, 12 Aug 2021 12:25:07 +0000 (14:25 +0200)
README.md

index dc14527c5d76608804705730c762508cad10c589..7867c59e955f25565dd1f633cbe8f9ec0a12c277 100644 (file)
--- a/README.md
+++ b/README.md
@@ -10,23 +10,32 @@ Add bundle custom repository to your project's `composer.json` file:
 {
     ...,
     "repositories": [
 {
     ...,
     "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
+<?php
+
+namespace CustomBundle\Entity;
+
+use Rapsys\UserBundle\Entity\User as BaseUser;
+
+class User extends BaseUser {}
+```
+
+Setup entity file `CustomBundle/Entity/Group.php` with the following content:
+
+```php
+<?php
+
+namespace CustomBundle\Entity;
+
+use Rapsys\GroupBundle\Entity\Group as BaseGroup;
+
+class Group extends BaseGroup {}
+```
+
+Setup entity file `CustomBundle/Entity/Civility.php` with the following content:
+
+```php
+<?php
+
+namespace CustomBundle\Entity;
+
+use Rapsys\CivilityBundle\Entity\Civility as BaseCivility;
+
+class Civility extends BaseCivility {}
+```