Skip to content

fix: Correct link to example plugins of B2B suite guides #1773

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

Merged
merged 3 commits into from
May 14, 2025
Merged
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
9 changes: 6 additions & 3 deletions products/extensions/b2b-suite/guides/core/audit-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ nav:

# Audit Log

[Download](../../../../../../products/extensions/b2b/b2b-suite/guides/example-plugins/B2bAcl.zip) a plugin showcasing the topic.
[Download](../example-plugins/B2bAcl.zip) a plugin showcasing the topic.

## Description

The B2B Suite provides a general audit log that can be implemented in every component.
The audit log component can save different log types and author information like first name, last name, and email. It provides a one-to-many association index. The database structure is described in the graphic below:
The audit log component can save different log types and author information like first name, last name, and email.
It provides a one-to-many association index.
The database structure is described in the graphic below:

```mermaid
classDiagram
Expand Down Expand Up @@ -41,7 +43,8 @@ classDiagram
}
```

As you can see, the database structure is very flat. In the `b2b_audit_log` table, we save a log type and a serialized *AuditLogValueEntity*.
As you can see, the database structure is very flat.
In the `b2b_audit_log` table, we save a log type and a serialized *AuditLogValueEntity*.
All required author information is saved in the `b2b_audit_log_author` table.

The `b2b_audit_log_index` saves all association data between an audit log and affected entities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nav:

# Storefront Authentication

[Download](../example-plugins/B2bAuth.zip) a plugin showcasing how to add a provider. You can [download](../../../../../../products/extensions/b2b/b2b-suite/guides/example-plugins/B2bLogin.zip) a plugin that exchange the login value.
[Download](../example-plugins/B2bAuth.zip) a plugin showcasing how to add a provider. You can [download](../example-plugins/B2bLogin.zip) a plugin that exchange the login value.

## Description

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nav:

# Overloading Classes

[Download](../../../../../../products/extensions/b2b/b2b-suite/guides/example-plugins/B2bServiceExtension.zip) a plugin showcasing the topic.
[Download](../example-plugins/B2bServiceExtension.zip) a plugin showcasing the topic.

## Description

Expand Down
20 changes: 13 additions & 7 deletions products/extensions/b2b-suite/guides/core/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ nav:

# REST API

[Download](../../../../../../products/extensions/b2b/b2b-suite/guides/example-plugins/B2bRestApi.zip) a plugin showcasing the topic.
[Download](../example-plugins/B2bRestApi.zip) a plugin showcasing the topic.

We use swagger.io for the documentation of our B2B Suite endpoints. The created [swagger.json](https://gitlab.com/shopware/shopware/enterprise/b2b/-/blob/minor/swagger.json) file can be displayed with [Swagger UI](https://swagger.io/tools/swagger-ui/).
We use swagger.io for the documentation of our B2B Suite endpoints.
The created [swagger.json](https://gitlab.com/shopware/shopware/enterprise/b2b/-/blob/minor/swagger.json) file can be displayed with [Swagger UI](https://swagger.io/tools/swagger-ui/).

## Description

The B2B Suite comes with its extension to the REST-API. Contrary to Shopware own implementation that makes heavy use
The B2B Suite comes with its extension to the REST-API.
Contrary to Shopware own implementation that makes heavy use
of the Doctrine ORM the B2B Suite reuses the same services defined for the Storefront.

## A simple example
Expand All @@ -40,10 +42,12 @@ class MyApiController

## Adding the route

Contrary to the default Shopware API, the B2B API provides deeply nested routes. All routes can be found at `http://my-shop.de/api/b2b`.
Contrary to the default Shopware API, the B2B API provides deeply nested routes.
All routes can be found at `http://my-shop.de/api/b2b`.
To register your own routes, you must add a `RouteProvider` to the routing service.

First, we create the routing provider containing all routing information. Routes themselves are defined as simple arrays, just like this:
First, we create the routing provider containing all routing information.
Routes themselves are defined as simple arrays, just like this:

```php
<?php declare(strict_types=1);
Expand Down Expand Up @@ -78,11 +82,13 @@ Now the route provider and the controller are registered to the DIC.
</service>
```

Notice that the route provider is tagged as a `b2b_common.rest_route_provider`. This tag triggers when the route is registered.
Notice that the route provider is tagged as a `b2b_common.rest_route_provider`.
This tag triggers when the route is registered.

## Complex routes

The used route parser is [FastRoute](https://github.com/nikic/FastRoute#defining-routes), which supports more powerful features that can also be used by the B2B API. Refer to this linked documentation to learn more about placeholders and placeholder parsing.
The used route parser is [FastRoute](https://github.com/nikic/FastRoute#defining-routes), which supports more powerful features that can also be used by the B2B API.
Refer to this linked documentation to learn more about placeholders and placeholder parsing.

If you want to use parameters, you have to define an order in which the parameters should be passed to the action:

Expand Down
44 changes: 28 additions & 16 deletions products/extensions/b2b-suite/guides/storefront/acl-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ nav:

# ACL and Routing

The ACL Routing component allows you to block Controller Actions for B2B users. It relies on and extends the technologies already defined by the ACL component. To accomplish this, the component directly maps an `action` in a given `controller` to a `resource` (= entity type) and `privilege` (= class of actions). There are two core actions you should know: `index` and `detail`, as you can see in the following acl-config example below.
The ACL Routing component allows you to block Controller Actions for B2B users.
It relies on and extends the technologies already defined by the ACL component.
To accomplish this, the component directly maps an `action` in a given `controller` to a `resource` (= entity type) and `privilege` (= class of actions).
There are two core actions you should know: `index` and `detail`, as you can see in the following acl-config example below.

## Registering routes

All routes that need access rights need to be stored in the database. The B2B Suite provides a service to simplify this process. For it to work correctly, you need an array in a specific format structured like this:
All routes that need access rights need to be stored in the database.
The B2B Suite provides a service to simplify this process.
For it to work correctly, you need an array in a specific format structured like this:

```php
$myAclConfig = [
Expand All @@ -34,31 +39,37 @@ Shopware\B2B\AclRoute\Framework\AclRoutingUpdateService::create()
->addConfig($myAclConfig);
```

This way, you can easily create and store the resources. Of course, to show a nice frontend, you must also provide snippets for translation. The snippets get automatically created from resource and privilege names and are prefixed with `_acl_`. So the resource `contingentgroup` needs a translation named `_acl_contingentgroup`.
This way, you can easily create and store the resources.
Of course, to show a nice frontend, you must also provide snippets for translation.
The snippets get automatically created from resource and privilege names and are prefixed with `_acl_`.
So the resource `contingentgroup` needs a translation named `_acl_contingentgroup`.

## Privilege names

The default privileges are:

| Privilege name | What it means |
|:----------------:|:-----------------------------------------------------------------------------------:|
| `list` | Entity listing (e.g. indexActions, gridActions) |
| `detail` | Disabled forms, lists of assignments, but only the inspection, not the modification |
| `create` | Creation of new entities |
| `delete` | Removal of existing entities |
| `update` | Updating/changing existing entities |
| `assign` | Changing the assignment of the entity |
| `free` | No restrictions |

It is quite natural to map CRUD actions like this. However, the assignment is a little less intuitive. This should help:
|:--------------:|:-----------------------------------------------------------------------------------:|
| `list` | Entity listing (e.g. indexActions, gridActions) |
| `detail` | Disabled forms, lists of assignments, but only the inspection, not the modification |
| `create` | Creation of new entities |
| `delete` | Removal of existing entities |
| `update` | Updating/changing existing entities |
| `assign` | Changing the assignment of the entity |
| `free` | No restrictions |

It is quite natural to map CRUD actions like this.
However, the assignment is a little less intuitive.
This should help:

* All assignment controllers belong to the resource on the right side of the assignment (e.g., the `B2BContactRole` controller is part of the `role` resource).
* All assignment listings have the detail privilege (e.g., `B2BContactRole:indexAction` is part of the `detail` privilege).
* All actions writing the assignment are part of the assign privilege (e.g. `B2BContactRole:assignAction` is part of the `assign` privilege).

## Automatic generation

You can autogenerate this format with the `RoutingIndexer`. This service expects a format that is automatically created by the *IndexerService*.
You can autogenerate this format with the `RoutingIndexer`.
This service expects a format that is automatically created by the *IndexerService*.
This could be part of your deployment or testing workflow.

```php
Expand Down Expand Up @@ -86,7 +97,8 @@ the action is new, and you must update the file to add the correct privilege nam

## Template extension

The ACL implementation is safe at the PHP level. Any route you have no access to will automatically be blocked, but for a better user experience, you should also extend the template to hide inaccessible actions.
The ACL implementation is safe at the PHP level.
Any route you have no access to will automatically be blocked, but for a better user experience, you should also extend the template to hide inaccessible actions.

```twig
<a href="{{ url("frontend.b2b." ~ page.route ~ ".assign") }}" class="{{ b2b_acl('b2broleaddress', 'assign') }}">
Expand Down Expand Up @@ -115,4 +127,4 @@ But there are certain specials to this:

## Download

Refer here for [simple example plugin](../../../../../../products/extensions/b2b/b2b-suite/guides/example-plugins/B2bAcl.zip).
Refer here for [simple example plugin](../example-plugins/B2bAcl.zip).