Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs for user extension. #170

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions Resources/doc/14-user-entity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# User entity

If you want to extend the user, that is used by the CommunityBundle, follow this guide.

## Config

Config for admin security:

```yml
# config/packages/admin_security.yaml

sulu_security:
objects:
user:
model: <your-entity>
```

Config for website security:

```
# config/packages/website_security.yaml

sulu_security:
objects:
user:
model: <your-entity>
```

**Replace `<your-entity>` with the the namespace plus name of your user entity (i.e. `App\Entity\User`).**

## User entity

In your own entity (i.e. `App\Entity\User`), which is supposed to act as your user entity throughout Sulu and the
CommunityBundle, the following is important:

You must override the default entity and therefore extend the `Sulu\Bundle\SecurityBundle\Entity\User` and make sure
to set the annotations accordingly: `@ORM\Table(name="se_users")`.

Follow the official Sulu docs for this:
[Sulu docs - Extend Entities](https://docs.sulu.io/en/2.5/cookbook/extend-entities.html#create-a-entity)

**Note: There are two ways to handle the configuration. The one mentioned above, which uses the default files
(`admin_security.yaml` and `website_security.yaml`) and alternatively, it is possible to use a seperate file
`config/packages/sulu_security.yaml` like in the
[Sulu docs - Extend Entities](https://docs.sulu.io/en/2.5/cookbook/extend-entities.html#configuration).
If the `sulu_security.yaml` is used, it overrides the configured parts of the configuration in `admin_security.yaml`
and `website_security.yaml`.**

## Finalizing

After making the changes to the configuration and creating the new entity, execute the following commands to make sure
the changes take effect.

1. Update the database schema:

```
$ php bin/adminconsole doctrine:schema:update --dump-sql
```

If the output of the command looks alright, execute the same command, but with `--force` instead of `--dump-sql`.

2. Clear cache:

```
$ php bin/adminconsole cache:clear
```
28 changes: 15 additions & 13 deletions Resources/doc/3-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sulu_community:
login:
embed_template: community/login-embed.html.twig
template: community/login.html.twig

# Registration
registration:
activate_user: false
Expand All @@ -44,9 +44,9 @@ sulu_community:
redirect_to: ?send=true
template: community/registration-form.html.twig
type: App\Form\RegistrationType

# Confirmation
confirmation:
confirmation:
activate_user: true
auto_login: true
email:
Expand All @@ -55,7 +55,7 @@ sulu_community:
admin_template: ~
redirect_to: ~
template: community/confirmation-message.html.twig

# Completion
completion:
email:
Expand All @@ -66,7 +66,7 @@ sulu_community:
service: ~
template: community/completion-form.html.twig
type: App\Form\CompletionType

# Password Forget / Reset
password_forget:
email:
Expand All @@ -85,7 +85,7 @@ sulu_community:
redirect_to: ?send=true
template: community/reset-form.html.twig
type: App\Form\PasswordResetType

# Profile
profile:
email:
Expand All @@ -95,15 +95,15 @@ sulu_community:
redirect_to: ~
template: community/profile-form.html.twig
type: App\Form\ProfileType

# Email Confirmation
email_confirmation:
email:
subject: Email Changed
user_template: community/email-confirmation-email.html.twig
admin_template: ~
template: community/email-confirmation-success.html.twig

# Blacklist
blacklisted:
email:
Expand Down Expand Up @@ -131,7 +131,7 @@ sulu_community:
Type: `integer`
Example: 600

When used cookie based login the last login timestamp will never
When used cookie based login the last login timestamp will never
be refreshed you can activate the last login refresh interval
which will refresh every given seconds the last login timestamp
to show example active users in your application.
Expand All @@ -141,7 +141,7 @@ to show example active users in your application.
Type: `string`
Example: [email protected]

Will be used as sender of all emails in this webspace.
Will be used as sender of all emails in this webspace.

#### to

Expand All @@ -156,7 +156,7 @@ If not configured it will fallback to the from configuration.
Type: `string`
Example: website

You can change the role name.
You can change the role name.
If not set it will generate it by webspace key and add 'User' as postfix.

#### firewall
Expand Down Expand Up @@ -215,15 +215,16 @@ The template used to render the user email, set to null to deactivate it.
Type: `string`
Example: ?send=true, app.redirect_route

redirect_to can be a url or a route_name. When containing `{localization}`
redirect_to can be a url or a route_name. When containing `{localization}`
it will be replaced with the current locale.

#### service

Type: `string`
Example: app.completion_validator

Service from interface `CompletionInterface` to validate if a user needs to add additional information before using your application.
Service from interface `CompletionInterface` to validate if a user needs to add additional information before using
your application.

#### template

Expand Down Expand Up @@ -251,3 +252,4 @@ The form type which is used to build the form.
- [Completion](11-completion.md)
- [Blacklisting](12-blacklisting.md)
- [Maintenance](13-maintenance.md)
- [User entity](14-user-entity.md)
2 changes: 2 additions & 0 deletions Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
7. [Email Confirmation](10-email-confirmation.md)
8. [Completion](11-completion.md)
9. [Blacklisting](12-blacklisting.md)
10. [Maintenance](13-maintenance.md)
11. [User entity](14-user-entity.md)