Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ca6adc

Browse files
committed
Fix whitespace and formatting in migration guides
This commit standardizes whitespace and formatting across several migration guide documentation files for forms, hooks, and testing. No functional or content changes were made; only formatting for improved readability and consistency.
1 parent f33d2aa commit 6ca6adc

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

development/architecture/migration-guide/forms/CQRS-usage-in-forms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight: 30
88
{{% notice note %}}
99
This article assumes that you are already familiar with CQRS and [CRUD forms]({{< relref "CRUD-forms" >}}), as this topic only demonstrates the usage of the CQRS approach.
1010
{{% /notice %}}
11-
11+
1212
## The basics
1313

1414
To use CQRS you need to:
@@ -123,9 +123,9 @@ public function create(array $data)
123123
$data['title'],
124124
$data['is_messages_saving_enabled']
125125
);
126-
126+
127127
$contactId = $this->commandBus->handle($addContactCommand);
128-
128+
129129
return $contactId->getValue();
130130
}
131131
```

development/architecture/migration-guide/forms/CRUD-forms.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ This guide is intended for core developers and contributors who want to understa
2121

2222
In computer programming, _CRUD_ is an acronym for the four basic functions of persistent storage: **create, read, update, and delete**.
2323

24-
PrestaShop handles several logic objects, like Cart, Product, Order, Customer... among many others. When such objects are stored using a unique identifier, we refer to them as **identifiable objects**.
24+
PrestaShop handles several logic objects, like Cart, Product, Order, Customer... among many others. When such objects are stored using a unique identifier, we refer to them as **identifiable objects**.
2525

26-
In the Back Office, most identifiable objects are managed using forms and page listings that follow the CRUD pattern. When they do, we refer to those forms as **CRUD Forms**.
26+
In the Back Office, most identifiable objects are managed using forms and page listings that follow the CRUD pattern. When they do, we refer to those forms as **CRUD Forms**.
2727

2828
Since CRUD forms share a lot of common behavior, PrestaShop provides a common pattern to handle them all the same way. It is based on four main elements, each responsible for a very specific task:
2929

@@ -43,11 +43,11 @@ The _Form Data Provider_ takes care of retrieving data to fill out a form. For t
4343
{{% funcdef %}}
4444

4545
getData(mixed $id): array
46-
:
46+
:
4747
Retrieves data for an edit form, using the given id to retrieve the object's data.
4848

4949
getDefaultData(): array
50-
:
50+
:
5151
Returns default data for a creation form.
5252

5353
{{% /funcdef %}}
@@ -56,9 +56,9 @@ getDefaultData(): array
5656

5757
To create a Form data provider you must implement the following interface:
5858

59-
\PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface
59+
\PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface
6060

61-
In the example below, you can see a `ContactFormDataProvider` that queries the database (in this case, using `ObjectModel`) to retrieve data when a specific identifiable object id (in this case, `Contact`) is given, and that returns static data with defaults to use when creating a new element.
61+
In the example below, you can see a `ContactFormDataProvider` that queries the database (in this case, using `ObjectModel`) to retrieve data when a specific identifiable object id (in this case, `Contact`) is given, and that returns static data with defaults to use when creating a new element.
6262

6363
```php
6464
<?php
@@ -78,7 +78,7 @@ final class ContactFormDataProvider implements FormDataProviderInterface
7878
public function getData($contactId)
7979
{
8080
$contactObjectModel = new Contact($contactId);
81-
81+
8282
// check that the element exists in db
8383
if (empty($contactObjectModel->id)) {
8484
throw new PrestaShopObjectNotFoundException('Object not found');
@@ -104,7 +104,7 @@ final class ContactFormDataProvider implements FormDataProviderInterface
104104
```
105105

106106
{{% notice note %}}
107-
**This example has been simplified for practical reasons.**
107+
**This example has been simplified for practical reasons.**
108108

109109
The core actually uses the CQRS pattern to retrieve data, instead of `ObjectModel`. For more information, have a look at our recommended approach on [how to use CQRS in forms]({{< relref "CQRS-usage-in-forms" >}}).
110110
{{% /notice %}}
@@ -135,17 +135,17 @@ The _Form Builder_ is used by controllers to build the form that will be shown t
135135

136136
It should be enough for most use cases, so you don't need to create it yourself! It also allows your form to be extended by modules.
137137
{{% /notice %}}
138-
138+
139139
The common methods that you will be using are:
140140

141141
{{% funcdef %}}
142142

143143
getForm(array $data = [], array $options = []): FormInterface
144-
:
144+
:
145145
Generates and returns the Symfony form. Additional `$data` and `$options` can be used in your form type.
146146

147147
getFormFor(mixed $id, array $data = [], array $options = []): FormInterface
148-
:
148+
:
149149
Generates and returns the Symfony form for an editable object which already exists and can be identified. Additional `$data` and `$options` can be used in your form type.
150150

151151
{{% /funcdef %}}
@@ -165,19 +165,19 @@ prestashop.core.form.identifiable_object.builder.contact_form_builder:
165165
- '@prestashop.core.form.identifiable_object.data_provider.contact_form_data_provider'
166166
```
167167

168-
In the example above, we are declaring a specific service for this form based on PrestaShop's implementation of the Form Builder:
168+
In the example above, we are declaring a specific service for this form based on PrestaShop's implementation of the Form Builder:
169169

170170
PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder
171-
171+
172172
...which is instantiated using the base factory:
173-
173+
174174
```text
175175
prestashop.core.form.builder.form_builder_factory:create
176176
```
177177

178178
...using two specific arguments:
179179

180-
- The **Form Type**'s class name
180+
- The **Form Type**'s class name
181181
- The **Form Data Provider**'s service name, that we declared previously.
182182

183183
Finally, use it in your controller:
@@ -216,11 +216,11 @@ The _Form Data Handler_ is responsible for persisting the data submitted through
216216
{{% funcdef %}}
217217

218218
create(array $data): mixed
219-
:
219+
:
220220
Creates a new identifiable object using the provided data and returns the created object's id.
221221

222222
update(mixed $id, array $data): void
223-
:
223+
:
224224
Updates the object identified by `$id` using the provided data
225225

226226
{{% /funcdef %}}
@@ -273,7 +273,7 @@ final class ContactFormDataHandler implements FormDataHandlerInterface
273273
```
274274

275275
{{% notice note %}}
276-
**This example has been simplified for practical reasons.**
276+
**This example has been simplified for practical reasons.**
277277

278278
The core actually uses the CQRS pattern to retrieve data, instead of `ObjectModel`. For more information, have a look at our recommended approach on [how to use CQRS in forms]({{< relref "CQRS-usage-in-forms" >}}).
279279
{{% /notice %}}
@@ -297,7 +297,7 @@ use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandl
297297

298298
## Form Handler
299299

300-
The _Form Handler_ is in charge of validating, enriching and saving submitted form data, using the provided [Form Data Handler](#form-data-handler).
300+
The _Form Handler_ is in charge of validating, enriching and saving submitted form data, using the provided [Form Data Handler](#form-data-handler).
301301

302302
{{% notice tip %}}
303303
**PrestaShop provides a default implementation for this object.**
@@ -309,27 +309,27 @@ It provides two methods:
309309

310310
{{% funcdef %}}
311311
handle(FormInterface $form): FormHandlerResultInterface
312-
:
312+
:
313313
Saves form data by creating new instance of the related identifiable object.
314314

315315
handleFor($id, FormInterface $form): FormHandlerResultInterface
316-
:
316+
:
317317
Saves form data by updating the related object identified by `$id`.
318318
{{% /funcdef %}}
319319

320320
Both methods return an instance of `FormHandlerResultInterface` that provides information about the process result:
321321

322322
{{% funcdef %}}
323323
isValid(): bool
324-
:
324+
:
325325
Indicates whether the form contains errors or not
326326

327327
isSubmitted(): bool
328-
:
328+
:
329329
Indicates if the form was submitted
330-
330+
331331
getIdentifiableObjectId(): mixed
332-
:
332+
:
333333
Returns the Id of the identifiable object created by the form submit, if applicable
334334
{{% /funcdef %}}
335335

@@ -369,7 +369,7 @@ public function createAction(Request $request)
369369
{
370370
$contactFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.contact_form_builder');
371371
$contactForm = $contactFormBuilder->getForm();
372-
372+
373373
$contactForm->handleRequest($request);
374374
375375
$contactFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.contact_form_handler');
@@ -380,7 +380,7 @@ public function createAction(Request $request)
380380
381381
return $this->redirectToRoute('admin_contacts_index');
382382
}
383-
383+
384384
return $this->render('@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/create.html.twig', [
385385
'contactForm' => $contactForm->createView(),
386386
]);
@@ -470,7 +470,7 @@ and
470470
```
471471

472472
{{% notice note %}}
473-
**This example has been simplified for practical reasons.**
473+
**This example has been simplified for practical reasons.**
474474

475475
The core actually uses CQRS to handle data persistence, which raises a `DomainException` in case of a constraint error (for example, if the identifiable object you are trying to edit doesn't exist). This is handled in the controller by wrapping the code in a try-catch block, then flashing an error message accordingly.
476476

development/architecture/migration-guide/forms/settings-forms.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The idea is to uncouple data management from Controllers, so populating the form
4646
## Form Handlers
4747

4848
Once you are able to manage data loaded to or sent by your forms, you need a way to build those forms (which can be themselves composed of multiple forms).
49-
49+
5050
For this, you need a Form Handler. You can either implement it yourself as a class (based on the interface `PrestaShop\PrestaShop\Core\Form\FormHandlerInterface`), or use PrestaShop's core `FormHandler` to create a service in a declarative way – no need for a new class!
5151

5252
As an example, here's how the Administration page's Form Handler service is declared:
@@ -68,17 +68,17 @@ prestashop.adapter.administration.general.form_handler:
6868
Let's look at the arguments one by one:
6969
7070
- `'@form.factory'`
71-
71+
7272
This is used to render the form. You can keep the default value.
73-
73+
7474
- `'@prestashop.core.hook.dispatcher'`
7575
7676
This is used to dispatch hooks related to the form. You can also keep this value by default.
77-
77+
7878
- `'@prestashop.adapter.administration.form_provider'`
79-
79+
8080
Here you need to specify your form's Data Provider.
81-
81+
8282
- `'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\GeneralType'`is the FQCN of the form type you want to render in your form.
8383
8484
- `'AdministrationPageGeneral'`
@@ -104,12 +104,12 @@ $form->handleRequest($request);
104104
if ($form->isSubmitted()) {
105105
$data = $form->getData();
106106
$saveErrors = $this->get('prestashop.adapter.performance.form_handler')->save($data);
107-
107+
108108
if (0 === count($saveErrors)) {
109109
$this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success'));
110110
return $this->redirectToRoute('admin_performance');
111111
}
112-
112+
113113
$this->flashErrors($saveErrors);
114114
}
115115

development/architecture/migration-guide/hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ file_put_contents('hooks.txt', PHP_EOL. $hook_name, FILE_APPEND | LOCK_EX);
2222
```
2323

2424
After applying this change, access the url of the page you want to migrate. In ``admin-dev/hooks.txt``, you'll see the list of available hooks in the legacy page.
25-
25+
2626
Now, create a simple module that hooks on each one of these hooks and renders something visible that you can retrieve in the new page.
2727

2828
{{% notice note %}}
@@ -47,7 +47,7 @@ $this->dispatchHook('actionAdminPerformanceControllerPostProcessBefore', array('
4747
## Dispatching hooks using the Hook dispatcher
4848

4949
If you need to dispatch a hook from a non-controller class, you'll need to inject the [HookDispatcher](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Hook/HookDispatcher.php) class.
50-
50+
5151
If your class is defined as a Symfony service, the HookDispatcher is available as a service called `prestashop.core.hook.dispatcher`.
5252

5353
```php

development/architecture/migration-guide/testing/behat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class OrderFeatureContext extends AbstractDomainFeatureContext
127127

128128
SharedStorage::getStorage()->set($orderReference, $orderId->getValue());
129129
}
130-
130+
131131
// ...
132132
```
133133

0 commit comments

Comments
 (0)