Skip to content

Commit

Permalink
Merge branch '2.0' into bootstrap-admin-panel
Browse files Browse the repository at this point in the history
* 2.0:
  Change application's version to v1.13.0-DEV
  Generate changelog for v1.13.0-RC.1
  Change application's version to v1.13.0-RC.1
  [Documentation] Update release dates for 1.13 and 2.0 versions
  [ECS] Fix nullable type declarations in the codebase
  [ECS] Fix nullable type declarations in Behat namespace
  [ECS] Add the NullableTypeDeclarationForDefaultNullValueFixer rule
  Add default label template in ShopBundle extending the UiBundle one
  Use extends instead of include in ShopBundle flashes template
  Manage confirmation modal for ShopBundle extending UiBundle
  Use Shop pagination macro in templates
  Use Shop messages macro in templates
  Use Shop flags macro in templates
  Use Shop headers macro in templates
  Use Shop buttons macro in templates
  [Documentation] Remove duplicated callback from state machine
  Update docs/book/architecture/state_machine.rst
  Add upmerging from 2.0 to api-platform-3
  Update php-entrypoint to give www-data permissions to public/media
  • Loading branch information
GSadee committed Apr 16, 2024
2 parents 384397e + f2bbfd1 commit ceb9294
Show file tree
Hide file tree
Showing 151 changed files with 276 additions and 237 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/upmerge_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
-
base_branch: "2.0"
target_branch: "bootstrap-admin-panel"
-
base_branch: "2.0"
target_branch: "api-platform-3"

steps:
-
Expand Down
79 changes: 53 additions & 26 deletions docs/book/architecture/state_machine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ How to configure states? Let's see on the example from **Checkout** state machin
cart: ~
addressed: ~
shipping_selected: ~
shipping_skipped: ~
payment_skipped: ~
payment_selected: ~
completed: ~
Expand All @@ -45,8 +47,8 @@ Having states configured we can have a transition between the ``cart`` state to
sylius_order_checkout:
transitions:
address:
from: [cart, addressed, shipping_selected, payment_selected] # here you specify which state is the initial
to: addressed # there you specify which state is final for that transition
from: [cart, addressed, shipping_selected, shipping_skipped, payment_selected, payment_skipped] # here you specify which state is the initial
to: addressed # there you specify which state is final for that transition
Callbacks
---------
Expand All @@ -65,9 +67,10 @@ Having a configured transition, you can attach a callback to it either before or
# callbacks may be called before or after specified transitions, in the checkout state machine we've got callbacks only after transitions
after:
sylius_process_cart:
on: ["address", "select_shipping", "select_payment"]
on: ["select_shipping", "address", "select_payment", "skip_shipping", "skip_payment"]
do: ["@sylius.order_processing.order_processor", "process"]
args: ["object"]
priority: -200
Configuration
-------------
Expand All @@ -76,8 +79,8 @@ In order to use a state machine, you have to define a graph beforehand.
A graph is a definition of states, transitions and optionally callbacks - all attached on an object from your domain.
Multiple graphs may be attached to the same object.

In **Sylius** the best example of a state machine is the one from checkout. It has five states available:
``cart``, ``addressed``, ``shipping_selected``, ``payment_selected`` and ``completed`` - which can be achieved by applying some transitions to the entity.
In **Sylius** the best example of a state machine is the one from checkout. It has seven states available:
``cart``, ``addressed``, ``shipping_selected``, ``shipping_skipped``, ``payment_skipped``, ``payment_selected`` and ``completed`` - which can be achieved by applying some transitions to the entity.
For example, when selecting a shipping method during the shipping step of checkout we should apply the ``select_shipping`` transition, and after that the state
would become ``shipping_selected``.

Expand All @@ -95,42 +98,66 @@ would become ``shipping_selected``.
cart: ~
addressed: ~
shipping_selected: ~
shipping_skipped: ~
payment_skipped: ~
payment_selected: ~
completed: ~
# list of all possible transitions:
transitions:
address:
from: [cart, addressed, shipping_selected, payment_selected] # here you specify which state is the initial
to: addressed # there you specify which state is final for that transition
from: [cart, addressed, shipping_selected, shipping_skipped, payment_selected, payment_skipped] # here you specify which state is the initial
to: addressed # there you specify which state is final for that transition
select_shipping:
from: [addressed, shipping_selected, payment_selected]
from: [addressed, shipping_selected, payment_selected, payment_skipped]
to: shipping_selected
skip_payment:
from: [shipping_selected, shipping_skipped]
to: payment_skipped
select_payment:
from: [payment_selected, shipping_selected]
from: [payment_selected, shipping_skipped, shipping_selected]
to: payment_selected
complete:
from: [payment_selected]
from: [payment_selected, payment_skipped]
to: completed
# list of all callbacks:
callbacks:
# callbacks may be called before or after specified transitions, in the checkout state machine we've got callbacks only after transitions
after:
sylius_process_cart:
on: ["address", "select_shipping", "select_payment"]
do: ["@sylius.order_processing.order_processor", "process"]
args: ["object"]
sylius_create_order:
on: ["complete"]
do: ["@sm.callback.cascade_transition", "apply"]
args: ["object", "event", "'create'", "'sylius_order'"]
sylius_hold_inventory:
on: ["complete"]
do: ["@sylius.inventory.order_inventory_operator", "hold"]
args: ["object"]
sylius_assign_token:
on: ["complete"]
do: ["@sylius.unique_id_based_order_token_assigner", "assignTokenValueIfNotSet"]
args: ["object"]
sylius_process_cart:
on: ["select_shipping", "address", "select_payment", "skip_shipping", "skip_payment"]
do: ["@sylius.order_processing.order_processor", "process"]
args: ["object"]
priority: -200
sylius_create_order:
on: ["complete"]
do: ["@sm.callback.cascade_transition", "apply"]
args: ["object", "event", "'create'", "'sylius_order'"]
priority: -400
sylius_save_checkout_completion_date:
on: ["complete"]
do: ["object", "completeCheckout"]
args: ["object"]
priority: -300
sylius_skip_shipping:
on: ["address"]
do: ["@sylius.state_resolver.order_checkout", "resolve"]
args: ["object"]
priority: -100
sylius_skip_payment:
on: ["select_shipping"]
do: ["@sylius.state_resolver.order_checkout", "resolve"]
args: ["object"]
priority: -100
sylius_control_payment_state:
on: ["complete"]
do: ["@sylius.state_resolver.order_payment", "resolve"]
args: ["object"]
priority: -200
sylius_control_shipping_state:
on: ["complete"]
do: ["@sylius.state_resolver.order_shipping", "resolve"]
args: ["object"]
priority: -100
Learn more
----------
Expand Down
4 changes: 2 additions & 2 deletions docs/book/organization/release-cycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ Future release
+---------+----------------------+------------------------+--------------------+
| Version | Development starts | Stabilization starts | Release date |
+=========+======================+========================+====================+
| 2.0 | Sep 15, 2023 | Q1 2024 | Q2 2024 |
| 2.0 | Sep 15, 2023 | Q2 2024 | Q3 2024 |
+---------+----------------------+------------------------+--------------------+
| 1.13 | Oct 31, 2022 | Q1 2024 | Q1 2024 |
| 1.13 | Oct 31, 2022 | Feb 15, 2024 | Apr 23, 2024 |
+---------+----------------------+------------------------+--------------------+

Supported versions
Expand Down
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
use PhpCsFixer\Fixer\LanguageConstruct\ErrorSuppressionFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
Expand All @@ -32,6 +33,7 @@
]);
$config->ruleWithConfiguration(PhpdocSeparationFixer::class, ['groups' => [['Given', 'When', 'Then']]]);
$config->ruleWithConfiguration(OrderedTypesFixer::class, ['null_adjustment' => 'always_last']);
$config->ruleWithConfiguration(NullableTypeDeclarationForDefaultNullValueFixer::class, ['use_nullable_type_declaration' => true]);
$config->ruleWithConfiguration(
HeaderCommentFixer::class,
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function iWantToCreateANewAdministrator(): void
* @When I do not specify its email
* @When I change its email to :email
*/
public function iSpecifyItsEmailAs(string $email = null): void
public function iSpecifyItsEmailAs(?string $email = null): void
{
if ($email !== null) {
$this->client->addRequestData('email', $email);
Expand All @@ -84,7 +84,7 @@ public function iSpecifyItsEmailAs(string $email = null): void
* @When I do not specify its name
* @When I change its name to :username
*/
public function iSpecifyItsNameAs(string $username = null): void
public function iSpecifyItsNameAs(?string $username = null): void
{
if ($username !== null) {
$this->client->addRequestData('username', $username);
Expand All @@ -104,7 +104,7 @@ public function iSpecifyItsFieldAsTooLongString(string $field): void
* @When I do not specify its password
* @When I change its password to :password
*/
public function iSpecifyItsPasswordAs(string $password = null): void
public function iSpecifyItsPasswordAs(?string $password = null): void
{
if ($password !== null) {
$this->client->addRequestData('plainPassword', $password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function iWantToCreateANewPaymentMethodWithWrongFactoryName(): void
* @When I specify its code as :code
* @When I do not specify its code
*/
public function iSpecifyItsCodeAs(string $code = null): void
public function iSpecifyItsCodeAs(?string $code = null): void
{
$this->client->addRequestData('code', $code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function iSpecifyItsCodeAs($productAssociationTypeCode): void
* @When I name it :productAssociationTypeName in :localeCode
* @When I do not name it
*/
public function iNameItIn(string $productAssociationTypeName = null, string $localeCode = 'en_US'): void
public function iNameItIn(?string $productAssociationTypeName = null, string $localeCode = 'en_US'): void
{
$this->client->updateRequestData([
'translations' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function iWantToCreateANewConfigurableProduct(): void
* @When I specify its code as :code
* @When I do not specify its code
*/
public function iSpecifyItsCodeAs(string $code = null): void
public function iSpecifyItsCodeAs(?string $code = null): void
{
$this->client->addRequestData('code', $code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function shipmentOfOrderShouldBe(
string $orderNumber,
string $shippingState,
CustomerInterface $customer,
ChannelInterface $channel = null,
?ChannelInterface $channel = null,
): void {
$this->client->index(Resources::SHIPMENTS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function iDescribeItAsIn(string $description, string $localeCode): void
* @When /^I define it for the (zone named "[^"]+")$/
* @When I do not specify its zone
*/
public function iDefineItForTheZone(ZoneInterface $zone = null): void
public function iDefineItForTheZone(?ZoneInterface $zone = null): void
{
if (null !== $zone) {
$this->client->addRequestData('zone', $this->iriConverter->getIriFromResource($zone));
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/PromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
* @When I use coupon with code :couponCode
* @When I remove coupon from my cart
*/
public function iUseCouponWithCode(string $couponCode = null): void
public function iUseCouponWithCode(?string $couponCode = null): void
{
$this->useCouponCode($couponCode);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Setup/CatalogPromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ private function createCatalogPromotion(
array $channels = [],
array $scopes = [],
array $actions = [],
int $priority = null,
?int $priority = null,
bool $exclusive = false,
?string $startDate = null,
?string $endDate = null,
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Context/Setup/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public function storeOperatesOnASingleChannelInLocale(string $localeCode): void
* @Given the store operates on a channel identified by :channelCode code
*/
public function theStoreOperatesOnAChannelNamed(
string $channelName = null,
string $currencyCode = null,
string $hostname = null,
string $channelCode = null,
?string $channelName = null,
?string $currencyCode = null,
?string $hostname = null,
?string $channelCode = null,
): void {
$channelCode = $channelCode ?? StringInflector::nameToLowercaseCode($channelName);
$channelName = $channelName ?? $channelCode;
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Setup/CheckoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ private function getDefaultAddress(): AddressInterface

private function completeCheckout(
OrderInterface $order,
ShippingMethodInterface $shippingMethod = null,
PaymentMethodInterface $paymentMethod = null,
?ShippingMethodInterface $shippingMethod = null,
?PaymentMethodInterface $paymentMethod = null,
): void {
$shippingMethod = $shippingMethod ?: $this->shippingMethodRepository->findOneBy([]);

Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Setup/CustomerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private function createCustomer(
$email,
$firstName = null,
$lastName = null,
\DateTimeInterface $createdAt = null,
?\DateTimeInterface $createdAt = null,
$phoneNumber = null,
) {
/** @var CustomerInterface $customer */
Expand Down
10 changes: 5 additions & 5 deletions src/Sylius/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(
* @Given /^the store(?:| also) has a product "([^"]+)" priced at ("[^"]+")$/
* @Given /^the store(?:| also) has a product "([^"]+)" priced at ("[^"]+") in ("[^"]+" channel)$/
*/
public function storeHasAProductPricedAt($productName, int $price = 100, ChannelInterface $channel = null): void
public function storeHasAProductPricedAt($productName, int $price = 100, ?ChannelInterface $channel = null): void
{
$product = $this->createProduct($productName, $price, $channel);

Expand Down Expand Up @@ -330,7 +330,7 @@ public function theProductHasVariantPricedAt(
ProductInterface $product,
$productVariantName,
$price,
ChannelInterface $channel = null,
?ChannelInterface $channel = null,
) {
$this->createProductVariant(
$product,
Expand Down Expand Up @@ -1368,7 +1368,7 @@ private function getPriceFromString(string $price): int
return (int) round((float) str_replace(['', '£', '$'], '', $price) * 100, 2);
}

private function createProduct(string $productName, int $price = 100, ChannelInterface $channel = null): ProductInterface
private function createProduct(string $productName, int $price = 100, ?ChannelInterface $channel = null): ProductInterface
{
if (null === $channel && $this->sharedStorage->has('channel')) {
$channel = $this->sharedStorage->get('channel');
Expand Down Expand Up @@ -1458,7 +1458,7 @@ private function createProductVariant(
$productVariantName,
$price,
$code,
ChannelInterface $channel = null,
?ChannelInterface $channel = null,
$position = null,
$shippingRequired = true,
int $currentStock = 0,
Expand Down Expand Up @@ -1549,7 +1549,7 @@ private function addProductVariantTranslation(ProductVariantInterface $productVa
$productVariant->addTranslation($translation);
}

private function createChannelPricingForChannel(int $price, ChannelInterface $channel = null): ChannelPricingInterface
private function createChannelPricingForChannel(int $price, ?ChannelInterface $channel = null): ChannelPricingInterface
{
/** @var ChannelPricingInterface $channelPricing */
$channelPricing = $this->channelPricingFactory->createNew();
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Setup/ProductReviewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function createProductReview(
$title,
$rating,
$comment,
CustomerInterface $customer = null,
?CustomerInterface $customer = null,
$transition = ProductReviewTransitions::TRANSITION_ACCEPT,
) {
/** @var ReviewInterface $review */
Expand Down
Loading

0 comments on commit ceb9294

Please sign in to comment.