Skip to content

Commit a88fc80

Browse files
committed
Adjusted code sample usage
1 parent 4afb98f commit a88fc80

File tree

18 files changed

+163
-180
lines changed

18 files changed

+163
-180
lines changed

code_samples/api/commerce/src/Command/CartCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __invoke(OutputInterface $output): int
9090
$this->cartService->emptyCart($cart);
9191

9292
// Validate a cart
93-
$violationList = $this->cartService->validateCart($cart); // Symfony\Component\Validator\ConstraintViolationListInterface
93+
$violationList = $this->cartService->validateCart($cart);
9494

9595
// Add product to a cart
9696
$product = $this->productService->getProduct('desk1');

docs/ai_actions/extend_ai_actions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For example, you can create a handler that connects to a translation model and u
1414
You can execute AI Actions by using the [ActionServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionServiceInterface.html) service, as in the following example:
1515

1616
``` php
17-
[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 86, 105) =]]
17+
[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php', 81, 100) =]]
1818
```
1919

2020
The `GenerateAltTextAction` is a built-in action that implements the [ActionInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html), takes an [Image](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-Action-DataType-Image.html) as an input, and generates the alternative text in the response.
@@ -43,7 +43,7 @@ You can influence the execution of an Action with two events:
4343
Below you can find the full example of a Symfony Command, together with a matching service definition.
4444
The command finds the images modified in the last 24 hours, and adds the alternative text to them if it's missing.
4545

46-
``` php hl_lines="72 85-110"
46+
``` php hl_lines="67 80-105"
4747
[[= include_file('code_samples/ai_actions/src/Command/AddMissingAltTextCommand.php') =]]
4848
```
4949

@@ -77,7 +77,7 @@ See [Action Configuration Search Criteria reference](action_configuration_criter
7777
The following example creates a new Action Configuration:
7878

7979
``` php hl_lines="3 17"
80-
[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 46, 63) =]]
80+
[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 40, 58) =]]
8181
```
8282

8383
Actions Configurations are tied to a specific Action Type and are translatable.
@@ -88,7 +88,7 @@ Reuse existing Action Configurations to simplify the execution of AI Actions.
8888
You can pass one directly to the `ActionServiceInterface::execute()` method:
8989

9090
``` php hl_lines="7-8"
91-
[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 64, 72) =]]
91+
[[= include_file('code_samples/ai_actions/src/Command/ActionConfigurationCreateCommand.php', 59, 67) =]]
9292
```
9393

9494
The passed Action Configuration is only taken into account if the Action Context was not passed to the Action directly using the [ActionInterface::setActionContext()](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorAi-ActionInterface.html#method_hasActionContext) method.

docs/api/php_api/php_api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ While [using `sudo()`](#using-sudo) is the recommended option, you can also set
126126
To identify as a different user, you need to use the `UserService` together with `PermissionResolver` (in the example `admin` is the login of the administrator user):
127127

128128
``` php
129-
[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 40, 41) =]]
129+
[[= include_file('code_samples/api/public_php_api/src/Command/CreateContentCommand.php', 36, 38) =]]
130130
```
131131

132132
!!! tip

docs/commerce/cart/cart_api.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ From the developer's perspective, carts and entries are referenced with a UUID i
2323
To access a single cart, use the `CartServiceInterface::getCart` method:
2424

2525
``` php
26-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 66) =]]
26+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 64) =]]
2727
```
2828

2929
## Get multiple carts
@@ -35,7 +35,7 @@ It follows the same search Query pattern as other APIs:
3535
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 10, 11) =]]
3636
// ...
3737

38-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 49, 57) =]]
38+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 47, 56) =]]
3939
```
4040

4141
## Create cart
@@ -46,7 +46,7 @@ To create a cart, use the `CartServiceInterface::createCart` method and provide
4646
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 8, 9) =]]
4747
// ...
4848

49-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 70, 78) =]]
49+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 68, 76) =]]
5050
```
5151

5252
## Update cart metadata
@@ -59,7 +59,7 @@ To update cart metadata, use the `CartServiceInterface::updateCartMetadata` meth
5959
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 9, 10) =]]
6060
// ...
6161

62-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 82, 89) =]]
62+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 80, 87) =]]
6363
```
6464

6565
You can also use this method to change cart ownership:
@@ -80,17 +80,17 @@ $cart = $cartService->updateCartMetadata($cart, $updateMetadataStruct);
8080
To delete a cart permanently, use the `CartServiceInterface::deleteCart` method and pass the `CartInterface` object:
8181

8282
``` php
83-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
84-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 124, 125) =]]
83+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 63) =]]
84+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 122, 124) =]]
8585
```
8686

8787
## Empty cart
8888

8989
To remove all products from the cart in a single operation, use the `CartServiceInterface::emptyCart` method:
9090

9191
``` php
92-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
93-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 91, 92) =]]
92+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]]
93+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 89, 91) =]]
9494
```
9595

9696
## Check cart validity
@@ -101,8 +101,8 @@ To validate the cart, use the `CartServiceInterface::validateCart` method.
101101
Validation is done with help from the `symfony/validator` component, and the method returns a `Symfony\Component\Validator\ConstraintViolationListInterface` object.
102102

103103
``` php
104-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
105-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 94, 95) =]]
104+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]]
105+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 92, 93) =]]
106106
```
107107

108108
## Add entry to cart
@@ -114,17 +114,17 @@ Then pass it to the `CartServiceInterface::addEntry` method:
114114
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 11, 12) =]]
115115
// ...
116116

117-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
118-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 99, 106) =]]
117+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]]
118+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 97, 104) =]]
119119
```
120120

121121
## Remove entry from cart
122122

123123
To remove an entry from the cart, use the `CartServiceInterface::removeEntry` method.
124124

125125
``` php
126-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
127-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 112) =]]
126+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]]
127+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 110) =]]
128128
```
129129

130130
## Update entry metadata
@@ -136,9 +136,9 @@ To change entry metadata, use the `CartServiceInterface::updateEntry` method and
136136
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 12, 13) =]]
137137
// ...
138138

139-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 63, 64) =]]
140-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 109, 110) =]]
141-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 114, 122) =]]
139+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 61, 62) =]]
140+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 107, 109) =]]
141+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 112, 120) =]]
142142
```
143143

144144
## Adding context data
@@ -185,5 +185,5 @@ To combine the contents of multiple shopping carts into a target cart, use the `
185185
This operation is helpful when you want to consolidate items from a reorder cart and a current cart into a single order.
186186

187187
```php
188-
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 126, 139) =]]
188+
[[= include_file('code_samples/api/commerce/src/Command/CartCommand.php', 125, 137) =]]
189189
```

docs/commerce/order_management/order_management_api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ To get orders and manage them, use the [`Ibexa\Contracts\OrderManagement\OrderSe
1919
To access a single order by using its string identifier, use the [`OrderServiceInterface::getOrderByIdentifier`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrderByIdentifier) method:
2020

2121
``` php
22-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]]
22+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 45, 49) =]]
2323
```
2424

2525
### Get single order by ID
2626

2727
To access a single order by using its numerical ID, use the [`OrderServiceInterface::getOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_getOrder) method:
2828

2929
``` php
30-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 57, 61) =]]
30+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 51, 55) =]]
3131
```
3232

3333
## Get multiple orders
@@ -36,18 +36,18 @@ To fetch multiple orders, use the [`OrderServiceInterface::findOrders`](/api/php
3636
It follows the same search query pattern as other APIs:
3737

3838
``` php
39-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 8, 9) =]][[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 10, 14) =]]
39+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 9, 14) =]]
4040

4141
// ...
42-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 110, 119) =]]
42+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 113) =]]
4343
```
4444

4545
## Create order
4646

4747
To create an order, use the [`OrderServiceInterface::createOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_createOrder) method and provide it with the [`Ibexa\Contracts\OrderManagement\Value\Struct\OrderCreateStruct`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-Value-Struct-OrderCreateStruct.html) object that contains a list of products, purchased quantities, product, total prices, and tax amounts.
4848

4949
``` php
50-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 91, 102) =]]
50+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 85, 96) =]]
5151
```
5252

5353
## Update order
@@ -57,5 +57,5 @@ You could do it to support a scenario when, for example, the order is processed
5757
To update order information, use the [`OrderServiceInterface::updateOrder`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-OrderManagement-OrderServiceInterface.html#method_updateOrder) method:
5858

5959
``` php
60-
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 104, 108) =]]
60+
[[= include_file('code_samples/api/commerce/src/Command/OrderCommand.php', 98, 102) =]]
6161
```

docs/commerce/payment/extend_payment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ When you create a payment, you can attach custom data to it, for example, you ca
9494
You add custom data by using the `setContext` method:
9595

9696
``` php
97-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 93) =]]
97+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 75, 87) =]]
9898
```
9999

100100
Then, you retrieve it with the `getContext` method:
101101

102102
``` php
103-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 58) =]]
103+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]]
104104
```

docs/commerce/payment/payment_api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ You can change that by providing a custom payment identifier in `Ibexa\Contracts
1717
To access a single payment by using its numerical ID, use the `PaymentServiceInterface::getPayment` method:
1818

1919
``` php
20-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 52) =]]
20+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 42, 46) =]]
2121
```
2222

2323
### Get single payment by identifier
2424

2525
To access a single payment by using its string identifier, use the `PaymentServiceInterface::getPaymentByIdentifier` method:
2626

2727
``` php
28-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 54, 56) =]]
28+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 48, 50) =]]
2929
```
3030

3131
## Get multiple payments
@@ -34,15 +34,15 @@ To fetch multiple payments, use the `PaymentServiceInterface::findPayments` meth
3434
It follows the same search query pattern as other APIs:
3535

3636
``` php
37-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 63, 79) =]]
37+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 57, 73) =]]
3838
```
3939

4040
## Create payment
4141

4242
To create a payment, use the `PaymentServiceInterface::createPayment` method and provide it with the `Ibexa\Contracts\Payment\Payment\PaymentCreateStruct` object that takes the following arguments: `method`, `order` and `amount`.
4343

4444
``` php
45-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 81, 95) =]]
45+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 75, 89) =]]
4646
```
4747

4848
## Update payment
@@ -53,13 +53,13 @@ The `Ibexa\Contracts\Payment\Payment\PaymentUpdateStruct` object takes the follo
5353
To update payment information, use the `PaymentServiceInterface::updatePayment` method:
5454

5555
``` php
56-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 97, 103) =]]
56+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 91, 97) =]]
5757
```
5858

5959
## Delete payment
6060

6161
To delete a payment from the system, use the `PaymentServiceInterface::deletePayment` method:
6262

6363
``` php
64-
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 105, 106) =]]
64+
[[= include_file('code_samples/api/commerce/src/Command/PaymentCommand.php', 99, 100) =]]
6565
```

docs/commerce/payment/payment_method_api.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ From the developer's perspective, payment methods are referenced with identifier
2626
To access a single payment method by using its string identifier, use the `PaymentMethodService::getPaymentMethodByIdentifier` method:
2727

2828
``` php
29-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 46, 50) =]]
29+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 44, 48) =]]
3030
```
3131

3232
### Get single payment method by ID
3333

3434
To access a single payment method by using its numerical ID, use the `PaymentMethodService::getPaymentMethod` method:
3535

3636
``` php
37-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 40, 44) =]]
37+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 38, 42) =]]
3838
```
3939

4040
## Get multiple payment methods
@@ -44,7 +44,7 @@ To fetch multiple payment methods, use the `PaymentMethodService::findPaymentMet
4444
It follows the same search query pattern as other APIs:
4545

4646
``` php
47-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 69) =]]
47+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 68) =]]
4848
```
4949

5050
## Create payment method
@@ -59,7 +59,7 @@ To create a payment method, use the `PaymentMethodService::createPaymentMethod`
5959
- `options` object.
6060

6161
``` php
62-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 52, 53) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 71, 81) =]]
62+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 50, 51) =]][[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 70, 79) =]]
6363
```
6464

6565
## Update payment method
@@ -70,20 +70,20 @@ An `Ibexa\Contracts\Payment\PaymentMethod\PaymentMethodUpdateStruct` object can
7070
To update payment method information, use the `PaymentMethodServiceInterface::updatePaymentMethod` method:
7171

7272
``` php
73-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 83, 93) =]]
73+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 81, 91) =]]
7474
```
7575

7676
## Delete payment method
7777

7878
To delete a payment method from the system, use the `PaymentMethodService::deletePayment` method:
7979
``` php
80-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 95, 101) =]]
80+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 93, 99) =]]
8181
```
8282

8383
## Check whether payment method is used
8484

8585
To check whether a payment method is used, for example, before you delete it, use the `PaymentMethodService::isPaymentMethodUsed` method:
8686

8787
``` php
88-
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 103, 116) =]]
88+
[[= include_file('code_samples/api/commerce/src/Command/PaymentMethodCommand.php', 101, 114) =]]
8989
```

docs/commerce/shipping_management/shipment_api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ From the developer's perspective, shipments are referenced with a UUID identifie
1616
To access a single shipment by using its string identifier, use the `ShipmentService::getShipmentByIdentifier` method:
1717

1818
``` php
19-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 57, 66) =]]
19+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 56, 64) =]]
2020
```
2121

2222
### Get single shipment by id
2323

2424
To access a single shipment by using its numerical id, use the `ShipmentService::getShipment` method:
2525

2626
``` php
27-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 45, 55) =]]
27+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 44, 53) =]]
2828
```
2929

3030
## Get multiple shipments
@@ -33,15 +33,15 @@ To fetch multiple shipments, use the `ShipmentService::findShipments` method.
3333
It follows the same search query pattern as other APIs:
3434

3535
``` php
36-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 68, 87) =]]
36+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 66, 85) =]]
3737
```
3838

3939
## Create shipment
4040

4141
To create a shipment, use the `ShipmentService::createShipment` method and provide it with an `Ibexa\Contracts\Shipping\Value\ShipmentCreateStruct` object that takes two parameters, a `shippingMethod` string and a `Money` object.
4242

4343
``` php
44-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 89, 103) =]]
44+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 87, 101) =]]
4545
```
4646

4747
## Update shipment
@@ -51,13 +51,13 @@ You could do it to support a scenario when, for example, the shipment is process
5151
To update shipment information, use the `ShipmentService::updateShipment` method:
5252

5353
``` php
54-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 105, 116) =]]
54+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 103, 114) =]]
5555
```
5656
## Delete shipment
5757

5858
To delete a shipment from the system, use the `ShipmentService::deleteShipment` method:
5959

6060

6161
``` php
62-
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 118, 119) =]]
62+
[[= include_file('code_samples/api/commerce/src/Command/ShipmentCommand.php', 116, 117) =]]
6363
```

0 commit comments

Comments
 (0)