diff --git a/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php b/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php index 2abc4ef87da..aa1bad8dda2 100644 --- a/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php @@ -204,20 +204,20 @@ protected function getDefinedElements(): array return array_merge(parent::getDefinedElements(), [ 'add_action_button' => '[data-test-actions] [data-test-add-%type%]', 'add_scope_button' => '[data-test-scopes] [data-test-add-%type%]', - 'channels' => '#sylius_catalog_promotion_channels', - 'description' => '[name="sylius_catalog_promotion[translations][%locale_code%][description]"]', - 'enabled' => '#sylius_catalog_promotion_enabled', - 'end_date_date' => '#sylius_catalog_promotion_endDate_date', - 'end_date_time' => '#sylius_catalog_promotion_endDate_time', - 'exclusive' => '#sylius_catalog_promotion_exclusive', + 'channels' => '#sylius_admin_catalog_promotion_channels', + 'description' => '[name="sylius_admin_catalog_promotion[translations][%locale_code%][description]"]', + 'enabled' => '#sylius_admin_catalog_promotion_enabled', + 'end_date_date' => '#sylius_admin_catalog_promotion_endDate_date', + 'end_date_time' => '#sylius_admin_catalog_promotion_endDate_time', + 'exclusive' => '#sylius_admin_catalog_promotion_exclusive', 'form' => '[data-live-name-value="sylius_admin:catalog_promotion:form"]', - 'label' => '[name="sylius_catalog_promotion[translations][%locale_code%][label]"]', + 'label' => '[name="sylius_admin_catalog_promotion[translations][%locale_code%][label]"]', 'last_action' => '[data-test-actions] [data-test-entry-row]:last-child', 'last_scope' => '[data-test-scopes] [data-test-entry-row]:last-child', - 'name' => '#sylius_catalog_promotion_name', - 'priority' => '#sylius_catalog_promotion_priority', - 'start_date_date' => '#sylius_catalog_promotion_startDate_date', - 'start_date_time' => '#sylius_catalog_promotion_startDate_time', + 'name' => '#sylius_admin_catalog_promotion_name', + 'priority' => '#sylius_admin_catalog_promotion_priority', + 'start_date_date' => '#sylius_admin_catalog_promotion_startDate_date', + 'start_date_time' => '#sylius_admin_catalog_promotion_startDate_time', ]); } } diff --git a/src/Sylius/Behat/Element/Admin/Channel/DiscountedProductsCheckingPeriodInputElement.php b/src/Sylius/Behat/Element/Admin/Channel/DiscountedProductsCheckingPeriodInputElement.php index 3e1c960bbe0..3ad6f396147 100644 --- a/src/Sylius/Behat/Element/Admin/Channel/DiscountedProductsCheckingPeriodInputElement.php +++ b/src/Sylius/Behat/Element/Admin/Channel/DiscountedProductsCheckingPeriodInputElement.php @@ -30,7 +30,7 @@ public function getPeriod(): int protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'discounted_products_checking_period' => '#sylius_channel_channelPriceHistoryConfig_lowestPriceForDiscountedProductsCheckingPeriod', + 'discounted_products_checking_period' => '#sylius_admin_channel_channelPriceHistoryConfig_lowestPriceForDiscountedProductsCheckingPeriod', ]); } } diff --git a/src/Sylius/Behat/Element/Admin/Channel/ShopBillingDataElement.php b/src/Sylius/Behat/Element/Admin/Channel/ShopBillingDataElement.php index 01a304af68c..82e44e414be 100644 --- a/src/Sylius/Behat/Element/Admin/Channel/ShopBillingDataElement.php +++ b/src/Sylius/Behat/Element/Admin/Channel/ShopBillingDataElement.php @@ -58,12 +58,12 @@ public function hasBillingAddress(string $street, string $postcode, string $city protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'city' => '#sylius_channel_shopBillingData_city', - 'company' => '#sylius_channel_shopBillingData_company', - 'country_code' => '#sylius_channel_shopBillingData_countryCode', - 'postcode' => '#sylius_channel_shopBillingData_postcode', - 'street' => '#sylius_channel_shopBillingData_street', - 'tax_id' => '#sylius_channel_shopBillingData_taxId', + 'city' => '#sylius_admin_channel_shopBillingData_city', + 'company' => '#sylius_admin_channel_shopBillingData_company', + 'country_code' => '#sylius_admin_channel_shopBillingData_countryCode', + 'postcode' => '#sylius_admin_channel_shopBillingData_postcode', + 'street' => '#sylius_admin_channel_shopBillingData_street', + 'tax_id' => '#sylius_admin_channel_shopBillingData_taxId', ]); } } diff --git a/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php b/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php index af8e3f0f1b8..b867252edaf 100644 --- a/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php @@ -151,8 +151,8 @@ public function selectAutocompleteRuleOptions(array $values, ?string $channelCod { $count = count($this->getElement('rules')->findAll('css', '[data-test-entry-row]')); $locator = $channelCode ? - sprintf('#sylius_promotion_rules_%d_configuration_%s select', $count - 1, $channelCode) : - sprintf('#sylius_promotion_rules_%d_configuration select', $count - 1) + sprintf('#sylius_admin_promotion_rules_%d_configuration_%s select', $count - 1, $channelCode) : + sprintf('#sylius_admin_promotion_rules_%d_configuration select', $count - 1) ; foreach ($values as $value) { $this->autocompleteHelper->selectByName( @@ -168,7 +168,7 @@ public function selectAutocompleteRuleOptions(array $values, ?string $channelCod public function selectAutocompleteActionFilterOptions(array $values, string $channelCode, string $filterType): void { $count = count($this->getElement('actions')->findAll('css', '[data-test-entry-row]')); - $locator = sprintf('#sylius_promotion_actions_%d_configuration_%s_filters_%s_filter select', $count - 1, $channelCode, $filterType); + $locator = sprintf('#sylius_admin_promotion_actions_%d_configuration_%s_filters_%s_filter select', $count - 1, $channelCode, $filterType); foreach ($values as $value) { $this->autocompleteHelper->selectByName( $this->getDriver(), @@ -217,31 +217,31 @@ public function getValidationMessageForTranslation(string $element, string $loca protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'action_amount' => '#sylius_promotion_actions_0_configuration_WEB-US_amount', - 'actions' => '#sylius_promotion_actions', + 'action_amount' => '#sylius_admin_promotion_actions_0_configuration_WEB-US_amount', + 'actions' => '#sylius_admin_promotion_actions', 'add_action_button' => '[data-test-actions] [data-test-add-%type%]', 'add_rule_button' => '[data-test-rules] [data-test-add-%type%]', - 'applies_to_discounted' => '#sylius_promotion_appliesToDiscounted', - 'channels' => '#sylius_promotion_channels', - 'code' => '#sylius_promotion_code', - 'coupon_based' => '#sylius_promotion_couponBased', - 'ends_at_date' => '#sylius_promotion_endsAt_date', - 'ends_at_time' => '#sylius_promotion_endsAt_time', - 'exclusive' => '#sylius_promotion_exclusive', + 'applies_to_discounted' => '#sylius_admin_promotion_appliesToDiscounted', + 'channels' => '#sylius_admin_promotion_channels', + 'code' => '#sylius_admin_promotion_code', + 'coupon_based' => '#sylius_admin_promotion_couponBased', + 'ends_at_date' => '#sylius_admin_promotion_endsAt_date', + 'ends_at_time' => '#sylius_admin_promotion_endsAt_time', + 'exclusive' => '#sylius_admin_promotion_exclusive', 'form' => '[data-live-name-value="sylius_admin:promotion:form"]', - 'label' => '[name="sylius_promotion[translations][%locale_code%][label]"]', + 'label' => '[name="sylius_admin_promotion[translations][%locale_code%][label]"]', 'last_action' => '[data-test-actions] [data-test-entry-row]:last-child', 'last_rule' => '[data-test-rules] [data-test-entry-row]:last-child', - 'minimum' => '#sylius_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_min', - 'maximum' => '#sylius_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_max', - 'name' => '#sylius_promotion_name', - 'priority' => '#sylius_promotion_priority', - 'rule_count' => '#sylius_promotion_rules_0_configuration_count', - 'rules' => '#sylius_promotion_rules', - 'starts_at_date' => '#sylius_promotion_startsAt_date', - 'starts_at_time' => '#sylius_promotion_startsAt_time', + 'minimum' => '#sylius_admin_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_min', + 'maximum' => '#sylius_admin_promotion_actions_0_configuration_WEB-US_filters_price_range_filter_max', + 'name' => '#sylius_admin_promotion_name', + 'priority' => '#sylius_admin_promotion_priority', + 'rule_count' => '#sylius_admin_promotion_rules_0_configuration_count', + 'rules' => '#sylius_admin_promotion_rules', + 'starts_at_date' => '#sylius_admin_promotion_startsAt_date', + 'starts_at_time' => '#sylius_admin_promotion_startsAt_time', 'translation_tab' => '[data-test-promotion-translations-accordion="%locale_code%"]', - 'usage_limit' => '#sylius_promotion_usageLimit', + 'usage_limit' => '#sylius_admin_promotion_usageLimit', ]); } @@ -257,7 +257,7 @@ private function getChannelConfigurationOfLastAction(string $channelCode): NodeE TabsHelper::switchTab($this->getSession(), $lastAction, $channelCode); return $lastAction - ->find('css', sprintf('[id^="sylius_promotion_actions_"][id$="_configuration_%s"]', $channelCode)) + ->find('css', sprintf('[id^="sylius_admin_promotion_actions_"][id$="_configuration_%s"]', $channelCode)) ; } @@ -274,7 +274,7 @@ private function getChannelConfigurationOfLastRule(string $channelCode): NodeEle return $lastRule->find( 'css', - sprintf('[id^="sylius_promotion_rules_"][id$="_configuration_%s"]', $channelCode), + sprintf('[id^="sylius_admin_promotion_rules_"][id$="_configuration_%s"]', $channelCode), ); } } diff --git a/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php b/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php index c3e4f77f719..75ecf142835 100644 --- a/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php @@ -150,21 +150,21 @@ protected function getDefinedElements(): array { return [ 'add_rule_button' => '[data-test-rules] [data-test-add-%type%]', - 'calculator' => '#sylius_shipping_method_calculator', - 'calculator_configuration_amount' => '#sylius_shipping_method_configuration_%channelCode%_amount', + 'calculator' => '#sylius_admin_shipping_method_calculator', + 'calculator_configuration_amount' => '#sylius_admin_shipping_method_configuration_%channelCode%_amount', 'calculator_configuration_channel_tab' => '[data-test-calculator-configuration] [data-test-channel-tab="%channelCode%"]', 'calculator_configuration_channel_tab_content' => '[data-test-calculator-configuration] [data-test-channel-tab-content="%channelCode%"]', - 'channel' => '[name="sylius_shipping_method[channels][]"][value="%channelCode%"]', - 'code' => '#sylius_shipping_method_code', - 'description' => '#sylius_shipping_method_translations_%localeCode%_description', - 'enabled' => '#sylius_shipping_method_enabled', + 'channel' => '[name="sylius_admin_shipping_method[channels][]"][value="%channelCode%"]', + 'code' => '#sylius_admin_shipping_method_code', + 'description' => '#sylius_admin_shipping_method_translations_%localeCode%_description', + 'enabled' => '#sylius_admin_shipping_method_enabled', 'form' => '[data-live-name-value="sylius_admin:shipping_method:form"]', 'last_rule' => '[data-test-rules] [data-test-entry-row]:last-child', 'last_rule_amount' => '[data-test-rules] [data-test-entry-row]:last-child [id$="_configuration_%channelCode%_amount"]', 'last_rule_weight' => '[data-test-rules] [data-test-entry-row]:last-child [id$="_configuration_weight"]', - 'name' => '#sylius_shipping_method_translations_%localeCode%_name', - 'position' => '#sylius_shipping_method_position', - 'zone' => '#sylius_shipping_method_zone', + 'name' => '#sylius_admin_shipping_method_translations_%localeCode%_name', + 'position' => '#sylius_admin_shipping_method_position', + 'zone' => '#sylius_admin_shipping_method_zone', ]; } diff --git a/src/Sylius/Behat/Page/Admin/Administrator/FormAwareTrait.php b/src/Sylius/Behat/Page/Admin/Administrator/FormAwareTrait.php index 2a4883320c7..5cfcd280dd0 100644 --- a/src/Sylius/Behat/Page/Admin/Administrator/FormAwareTrait.php +++ b/src/Sylius/Behat/Page/Admin/Administrator/FormAwareTrait.php @@ -109,15 +109,15 @@ protected function getDefinedFormElements(): array { return [ 'avatar_image' => '[data-test-avatar-image]', - 'field_avatar' => '#sylius_admin_user_avatar_file', - 'field_email' => '#sylius_admin_user_email', - 'field_enabled' => '#sylius_admin_user_enabled', - 'field_first_name' => '#sylius_admin_user_firstName', - 'field_last_name' => '#sylius_admin_user_lastName', - 'field_locale_code' => '#sylius_admin_user_localeCode', - 'field_name' => '#sylius_admin_user_username', - 'field_password' => '#sylius_admin_user_plainPassword', - 'field_username' => '#sylius_admin_user_username', + 'field_avatar' => '#sylius_admin_admin_user_avatar_file', + 'field_email' => '#sylius_admin_admin_user_email', + 'field_enabled' => '#sylius_admin_admin_user_enabled', + 'field_first_name' => '#sylius_admin_admin_user_firstName', + 'field_last_name' => '#sylius_admin_admin_user_lastName', + 'field_locale_code' => '#sylius_admin_admin_user_localeCode', + 'field_name' => '#sylius_admin_admin_user_username', + 'field_password' => '#sylius_admin_admin_user_plainPassword', + 'field_username' => '#sylius_admin_admin_user_username', ]; } } diff --git a/src/Sylius/Behat/Page/Admin/CatalogPromotion/CreatePage.php b/src/Sylius/Behat/Page/Admin/CatalogPromotion/CreatePage.php index 8755f105c35..8ecc988be47 100644 --- a/src/Sylius/Behat/Page/Admin/CatalogPromotion/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/CatalogPromotion/CreatePage.php @@ -23,8 +23,8 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_catalog_promotion_code', - 'name' => '#sylius_catalog_promotion_name', + 'code' => '#sylius_admin_catalog_promotion_code', + 'name' => '#sylius_admin_catalog_promotion_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/CatalogPromotion/UpdatePage.php b/src/Sylius/Behat/Page/Admin/CatalogPromotion/UpdatePage.php index e928a8d5807..686143d697e 100644 --- a/src/Sylius/Behat/Page/Admin/CatalogPromotion/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/CatalogPromotion/UpdatePage.php @@ -29,7 +29,7 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_catalog_promotion_code', + 'code' => '#sylius_admin_catalog_promotion_code', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Channel/FormTrait.php b/src/Sylius/Behat/Page/Admin/Channel/FormTrait.php index 138201da88f..29117e85b0d 100644 --- a/src/Sylius/Behat/Page/Admin/Channel/FormTrait.php +++ b/src/Sylius/Behat/Page/Admin/Channel/FormTrait.php @@ -23,9 +23,9 @@ public function getDefinedFormElements(): array 'color' => '[data-test-color]', 'contact_email' => '[data-test-contact-email]', 'contact_phone_number' => '[data-test-contact-phone-number]', - 'countries' => '#sylius_channel_countries', - 'currencies' => '#sylius_channel_currencies', - 'default_locale' => '#sylius_channel_defaultLocale', + 'countries' => '#sylius_admin_channel_countries', + 'currencies' => '#sylius_admin_channel_currencies', + 'default_locale' => '#sylius_admin_channel_defaultLocale', 'default_tax_zone' => '[data-test-default-tax-zone]', 'discounted_products_checking_period' => '[data-test-lowest-price-for-discounted-products-checking-period]', 'enabled' => '[data-test-enabled]', diff --git a/src/Sylius/Behat/Page/Admin/Currency/CreatePage.php b/src/Sylius/Behat/Page/Admin/Currency/CreatePage.php index 48f663c072e..e0f2a7d938d 100644 --- a/src/Sylius/Behat/Page/Admin/Currency/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Currency/CreatePage.php @@ -28,8 +28,8 @@ public function specifyExchangeRate(float $exchangeRate): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_currency_code', - 'exchangeRate' => '#sylius_currency_exchangeRate', + 'code' => '#sylius_admin_currency_code', + 'exchangeRate' => '#sylius_admin_currency_exchangeRate', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Currency/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Currency/UpdatePage.php index 2961c19e2aa..f04420543a7 100644 --- a/src/Sylius/Behat/Page/Admin/Currency/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Currency/UpdatePage.php @@ -57,9 +57,9 @@ protected function getToggleableElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_currency_code', - 'enabled' => '#sylius_currency_enabled', - 'exchangeRate' => '#sylius_currency_exchangeRate', + 'code' => '#sylius_admin_currency_code', + 'enabled' => '#sylius_admin_currency_enabled', + 'exchangeRate' => '#sylius_admin_currency_exchangeRate', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Customer/CreatePage.php b/src/Sylius/Behat/Page/Admin/Customer/CreatePage.php index 6fd6f77e49d..7cd1b22ecd7 100644 --- a/src/Sylius/Behat/Page/Admin/Customer/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Customer/CreatePage.php @@ -54,12 +54,12 @@ public function chooseGroup(string $group): void public function selectCreateAccount(): void { - $this->getDocument()->find('css', 'label[for=sylius_customer_createUser]')->click(); + $this->getDocument()->find('css', 'label[for=sylius_admin_customer_createUser]')->click(); } public function hasPasswordField(): bool { - return null !== $this->getDocument()->find('css', '#sylius_customer_user_plainPassword'); + return null !== $this->getDocument()->find('css', '#sylius_admin_customer_user_plainPassword'); } public function hasCheckedCreateOption(): bool @@ -69,7 +69,7 @@ public function hasCheckedCreateOption(): bool public function hasCreateOption(): bool { - return null !== $this->getDocument()->find('css', '#sylius_customer_createUser'); + return null !== $this->getDocument()->find('css', '#sylius_admin_customer_createUser'); } public function isUserFormHidden(): bool @@ -80,11 +80,11 @@ public function isUserFormHidden(): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'create_customer_user' => '#sylius_customer_createUser', - 'email' => '#sylius_customer_email', - 'first_name' => '#sylius_customer_firstName', - 'last_name' => '#sylius_customer_lastName', - 'password' => '#sylius_customer_user_plainPassword', + 'create_customer_user' => '#sylius_admin_customer_createUser', + 'email' => '#sylius_admin_customer_email', + 'first_name' => '#sylius_admin_customer_firstName', + 'last_name' => '#sylius_admin_customer_lastName', + 'password' => '#sylius_admin_customer_user_plainPassword', 'user_form' => '#user-form', ]); } diff --git a/src/Sylius/Behat/Page/Admin/Customer/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Customer/UpdatePage.php index 7ecb952e709..23f4d68e1e6 100644 --- a/src/Sylius/Behat/Page/Admin/Customer/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Customer/UpdatePage.php @@ -92,13 +92,13 @@ protected function getToggleableElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'email' => '#sylius_customer_email', - 'enabled' => '#sylius_customer_user_enabled', - 'first_name' => '#sylius_customer_firstName', - 'group' => '#sylius_customer_group', - 'last_name' => '#sylius_customer_lastName', - 'password' => '#sylius_customer_user_password', - 'verified_at' => '#sylius_customer_user_verifiedAt', + 'email' => '#sylius_admin_customer_email', + 'enabled' => '#sylius_admin_customer_user_enabled', + 'first_name' => '#sylius_admin_customer_firstName', + 'group' => '#sylius_admin_customer_group', + 'last_name' => '#sylius_admin_customer_lastName', + 'password' => '#sylius_admin_customer_user_password', + 'verified_at' => '#sylius_admin_customer_user_verifiedAt', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/CustomerGroup/CreatePage.php b/src/Sylius/Behat/Page/Admin/CustomerGroup/CreatePage.php index fd4320eeb7b..e6235d67b46 100644 --- a/src/Sylius/Behat/Page/Admin/CustomerGroup/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/CustomerGroup/CreatePage.php @@ -25,8 +25,8 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_customer_group_code', - 'name' => '#sylius_customer_group_name', + 'code' => '#sylius_admin_customer_group_code', + 'name' => '#sylius_admin_customer_group_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/CustomerGroup/UpdatePage.php b/src/Sylius/Behat/Page/Admin/CustomerGroup/UpdatePage.php index ec4942538cb..3fe99add363 100644 --- a/src/Sylius/Behat/Page/Admin/CustomerGroup/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/CustomerGroup/UpdatePage.php @@ -34,8 +34,8 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_customer_group_code', - 'name' => '#sylius_customer_group_name', + 'code' => '#sylius_admin_customer_group_code', + 'name' => '#sylius_admin_customer_group_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ExchangeRate/CreatePage.php b/src/Sylius/Behat/Page/Admin/ExchangeRate/CreatePage.php index e21fc71d822..e903b279a86 100644 --- a/src/Sylius/Behat/Page/Admin/ExchangeRate/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/ExchangeRate/CreatePage.php @@ -45,9 +45,9 @@ public function hasFormValidationError(string $expectedMessage): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'source currency' => '#sylius_exchange_rate_sourceCurrency', - 'target currency' => '#sylius_exchange_rate_targetCurrency', - 'ratio' => '#sylius_exchange_rate_ratio', + 'source currency' => '#sylius_admin_exchange_rate_sourceCurrency', + 'target currency' => '#sylius_admin_exchange_rate_targetCurrency', + 'ratio' => '#sylius_admin_exchange_rate_ratio', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ExchangeRate/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ExchangeRate/UpdatePage.php index 7c5d83ba844..e1e295cead2 100644 --- a/src/Sylius/Behat/Page/Admin/ExchangeRate/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ExchangeRate/UpdatePage.php @@ -40,9 +40,9 @@ public function isTargetCurrencyDisabled(): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'ratio' => '#sylius_exchange_rate_ratio', - 'sourceCurrency' => '#sylius_exchange_rate_sourceCurrency', - 'targetCurrency' => '#sylius_exchange_rate_targetCurrency', + 'ratio' => '#sylius_admin_exchange_rate_ratio', + 'sourceCurrency' => '#sylius_admin_exchange_rate_sourceCurrency', + 'targetCurrency' => '#sylius_admin_exchange_rate_targetCurrency', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Order/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Order/UpdatePage.php index 98e6471e92e..e249cda24e3 100644 --- a/src/Sylius/Behat/Page/Admin/Order/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Order/UpdatePage.php @@ -96,23 +96,23 @@ private function getOptionTextsFor(NodeElement $element): array protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'billing_city' => '#sylius_order_billingAddress_city', - 'billing_country' => '#sylius_order_billingAddress_countryCode', - 'billing_first_name' => '#sylius_order_billingAddress_firstName', - 'billing_last_name' => '#sylius_order_billingAddress_lastName', - 'billing_postcode' => '#sylius_order_billingAddress_postcode', - 'billing_province_name' => '#sylius_order_billingAddress_provinceName', - 'billing_province_code' => '#sylius_order_billingAddress_provinceCode', - 'billing_street' => '#sylius_order_billingAddress_street', + 'billing_city' => '#sylius_admin_order_billingAddress_city', + 'billing_country' => '#sylius_admin_order_billingAddress_countryCode', + 'billing_first_name' => '#sylius_admin_order_billingAddress_firstName', + 'billing_last_name' => '#sylius_admin_order_billingAddress_lastName', + 'billing_postcode' => '#sylius_admin_order_billingAddress_postcode', + 'billing_province_name' => '#sylius_admin_order_billingAddress_provinceName', + 'billing_province_code' => '#sylius_admin_order_billingAddress_provinceCode', + 'billing_street' => '#sylius_admin_order_billingAddress_street', 'live_form' => '[data-live-name-value="sylius_admin:order:form"]', - 'shipping_city' => '#sylius_order_shippingAddress_city', - 'shipping_country' => '#sylius_order_shippingAddress_countryCode', - 'shipping_first_name' => '#sylius_order_shippingAddress_firstName', - 'shipping_last_name' => '#sylius_order_shippingAddress_lastName', - 'shipping_postcode' => '#sylius_order_shippingAddress_postcode', - 'shipping_province_name' => '#sylius_order_shippingAddress_provinceName', - 'shipping_province_code' => '#sylius_order_shippingAddress_provinceCode', - 'shipping_street' => '#sylius_order_shippingAddress_street', + 'shipping_city' => '#sylius_admin_order_shippingAddress_city', + 'shipping_country' => '#sylius_admin_order_shippingAddress_countryCode', + 'shipping_first_name' => '#sylius_admin_order_shippingAddress_firstName', + 'shipping_last_name' => '#sylius_admin_order_shippingAddress_lastName', + 'shipping_postcode' => '#sylius_admin_order_shippingAddress_postcode', + 'shipping_province_name' => '#sylius_admin_order_shippingAddress_provinceName', + 'shipping_province_code' => '#sylius_admin_order_shippingAddress_provinceCode', + 'shipping_street' => '#sylius_admin_order_shippingAddress_street', ]); } diff --git a/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php b/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php index 7c1ed6e2340..09fc8e3fc28 100644 --- a/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php @@ -28,7 +28,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface public function nameIt(string $name, string $languageCode): void { $this->getDocument()->fillField( - sprintf('sylius_payment_method_translations_%s_name', $languageCode), + sprintf('sylius_admin_payment_method_translations_%s_name', $languageCode), $name, ); } @@ -46,7 +46,7 @@ public function checkChannel(string $channelName): void public function describeIt(string $description, string $languageCode): void { $this->getDocument()->fillField( - sprintf('sylius_payment_method_translations_%s_description', $languageCode), + sprintf('sylius_admin_payment_method_translations_%s_description', $languageCode), $description, ); } @@ -54,7 +54,7 @@ public function describeIt(string $description, string $languageCode): void public function setInstructions(string $instructions, string $languageCode): void { $this->getDocument()->fillField( - sprintf('sylius_payment_method_translations_%s_instructions', $languageCode), + sprintf('sylius_admin_payment_method_translations_%s_instructions', $languageCode), $instructions, ); } @@ -106,13 +106,13 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'cancel_button' => '[data-test-cancel-changes-button]', - 'code' => '#sylius_payment_method_code', - 'enabled' => '#sylius_payment_method_enabled', - 'gateway_name' => '#sylius_payment_method_gatewayConfig_gatewayName', - 'name' => '#sylius_payment_method_translations_en_US_name', - 'paypal_password' => '#sylius_payment_method_gatewayConfig_config_password', - 'stripe_secret_key' => '#sylius_payment_method_gatewayConfig_config_secret_key', - 'stripe_publishable_key' => '#sylius_payment_method_gatewayConfig_config_publishable_key', + 'code' => '#sylius_admin_payment_method_code', + 'enabled' => '#sylius_admin_payment_method_enabled', + 'gateway_name' => '#sylius_admin_payment_method_gatewayConfig_gatewayName', + 'name' => '#sylius_admin_payment_method_translations_en_US_name', + 'paypal_password' => '#sylius_admin_payment_method_gatewayConfig_config_password', + 'stripe_secret_key' => '#sylius_admin_payment_method_gatewayConfig_config_secret_key', + 'stripe_publishable_key' => '#sylius_admin_payment_method_gatewayConfig_config_publishable_key', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/PaymentMethod/UpdatePage.php b/src/Sylius/Behat/Page/Admin/PaymentMethod/UpdatePage.php index 6996269a533..04433553ccc 100644 --- a/src/Sylius/Behat/Page/Admin/PaymentMethod/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/PaymentMethod/UpdatePage.php @@ -50,7 +50,7 @@ public function setStripePublishableKey(string $publishableKey): void public function nameIt(string $name, string $languageCode): void { - $this->getDocument()->fillField(sprintf('sylius_payment_method_translations_%s_name', $languageCode), $name); + $this->getDocument()->fillField(sprintf('sylius_admin_payment_method_translations_%s_name', $languageCode), $name); } public function enableSandboxMode(): void @@ -106,8 +106,8 @@ protected function getDefinedElements(): array 'code' => '[data-test-code]', 'enabled' => '[data-test-enabled]', 'factory_name' => '[data-test-factory-name]', - 'instructions' => '#sylius_payment_method_translations_%language%_instructions', - 'name' => '#sylius_payment_method_translations_en_US_name', + 'instructions' => '#sylius_admin_payment_method_translations_%language%_instructions', + 'name' => '#sylius_admin_payment_method_translations_en_US_name', 'password' => '[data-test-password]', 'publishable_key' => '[data-test-publishable-key]', 'sandbox' => '[data-test-sandbox]', diff --git a/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php index 4d521c21614..659ff5282a0 100644 --- a/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php @@ -182,12 +182,12 @@ protected function getDefinedElements(): array 'product_taxons' => '#sylius_product_productTaxons', 'name' => '#sylius_product_translations_%locale%_name', 'non_translatable_attribute_value' => '#attributesContainer [data-test-product-attribute-value-in-locale="%attributeName% "] input', - 'original_price' => '#sylius_product_variant_channelPricings_%channelCode%_originalPrice', - 'price' => '#sylius_product_variant_channelPricings_%channelCode%_price', - 'prices_validation_message' => '#sylius_product_variant_channelPricings ~ .sylius-validation-error, #sylius_product_variant_channelPricings .sylius-validation-error', - 'price_calculator' => '#sylius_product_variant_pricingCalculator', - 'shipping_category' => '#sylius_product_variant_shippingCategory', - 'shipping_required' => '#sylius_product_variant_shippingRequired', + 'original_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_originalPrice', + 'price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_price', + 'prices_validation_message' => '#sylius_admin_product_variant_channelPricings ~ .sylius-validation-error, #sylius_admin_product_variant_channelPricings .sylius-validation-error', + 'price_calculator' => '#sylius_admin_product_variant_pricingCalculator', + 'shipping_category' => '#sylius_admin_product_variant_shippingCategory', + 'shipping_required' => '#sylius_admin_product_variant_shippingRequired', 'slug' => '#sylius_product_translations_%locale%_slug', 'tab' => '.menu [data-tab="%name%"]', 'taxonomy' => 'a[data-tab="taxonomy"]', diff --git a/src/Sylius/Behat/Page/Admin/Product/FormTrait.php b/src/Sylius/Behat/Page/Admin/Product/FormTrait.php index 237dfa216a5..b44e0f6851d 100644 --- a/src/Sylius/Behat/Page/Admin/Product/FormTrait.php +++ b/src/Sylius/Behat/Page/Admin/Product/FormTrait.php @@ -29,13 +29,13 @@ public function getDefinedFormElements(): array 'attribute_value' => '[data-test-attribute-value][data-test-locale-code="%localeCode%"][data-test-attribute-name="%attributeName%"]', 'channel_tab' => '[data-test-channel-tab="%channelCode%"]', 'form' => '[data-live-name-value="sylius_admin:product:form"]', - 'field_associations' => '[name="sylius_product[associations][%association%][]"]', - 'field_name' => '[name="sylius_product[translations][%localeCode%][name]"]', - 'field_slug' => '[name="sylius_product[translations][%localeCode%][slug]"]', - 'field_price' => '[name="sylius_product[variant][channelPricings][%channelCode%][price]"]', - 'field_original_price' => '[name="sylius_product[variant][channelPricings][%channelCode%][originalPrice]"]', - 'field_shipping_category' => '[name="sylius_product[variant][shippingCategory]"]', - 'field_shipping_required' => '[name="sylius_product[variant][shippingRequired]"]', + 'field_associations' => '[name="sylius_admin_product[associations][%association%][]"]', + 'field_name' => '[name="sylius_admin_product[translations][%localeCode%][name]"]', + 'field_slug' => '[name="sylius_admin_product[translations][%localeCode%][slug]"]', + 'field_price' => '[name="sylius_admin_product[variant][channelPricings][%channelCode%][price]"]', + 'field_original_price' => '[name="sylius_admin_product[variant][channelPricings][%channelCode%][originalPrice]"]', + 'field_shipping_category' => '[name="sylius_admin_product[variant][shippingCategory]"]', + 'field_shipping_required' => '[name="sylius_admin_product[variant][shippingRequired]"]', 'generate_product_slug_button' => '[data-test-generate-product-slug-button="%localeCode%"]', 'images' => '[data-test-images]', 'image_subform' => '[data-test-image-subform]', diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php index cb2f439adb3..4932c5d6f55 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php @@ -153,7 +153,7 @@ protected function getDefinedElements(): array 'main_taxon' => '#sylius_product_mainTaxon', 'name' => '#sylius_product_translations_en_US_name', 'options' => '#sylius_product_options', - 'price' => '#sylius_product_variant_price', + 'price' => '#sylius_admin_product_variant_price', 'search' => '.ui.fluid.search.selection.dropdown', 'search_item_selected' => 'div.menu > div.item.selected', 'tab' => '.menu [data-tab="%name%"]', diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php index d275d8c2869..11d83c3abd7 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php @@ -354,9 +354,9 @@ protected function getDefinedElements(): array 'language_tab' => '[data-locale="%locale%"] .title', 'locale_tab' => '#attributesContainer [data-test-product-attribute-value-in-locale="%attributeName% %localeCode%"]', 'name' => '#sylius_product_translations_%locale%_name', - 'prices' => '#sylius_product_variant_channelPricings', - 'original_price' => '#sylius_product_variant_channelPricings input[name$="[originalPrice]"][id*="%channelCode%"]', - 'price' => '#sylius_product_variant_channelPricings input[id*="%channelCode%"]', + 'prices' => '#sylius_admin_product_variant_channelPricings', + 'original_price' => '#sylius_admin_product_variant_channelPricings input[name$="[originalPrice]"][id*="%channelCode%"]', + 'price' => '#sylius_admin_product_variant_channelPricings input[id*="%channelCode%"]', 'pricing_configuration' => '#sylius_calculator_container', 'main_taxon' => '#sylius_product_mainTaxon', 'meta_description' => '#sylius_product_translations_%locale%_metaDescription', @@ -364,12 +364,12 @@ protected function getDefinedElements(): array 'non_translatable_attribute' => '#attributesContainer [data-test-product-attribute-value-in-locale="%attributeName% "] input', 'product_taxon' => '#sylius-product-taxonomy-tree .item .header:contains("%taxonName%") input', 'product_taxons' => '#sylius_product_productTaxons', - 'shipping_required' => '#sylius_product_variant_shippingRequired', + 'shipping_required' => '#sylius_admin_product_variant_shippingRequired', 'show_product_button' => '[data-test-view-in-store]', 'slug' => '#sylius_product_translations_%locale%_slug', 'tab' => '.menu [data-tab="%name%"]', 'taxonomy' => 'a[data-tab="taxonomy"]', - 'tracked' => '#sylius_product_variant_tracked', + 'tracked' => '#sylius_admin_product_variant_tracked', 'toggle_slug_modification_button' => '[data-locale="%locale%"] .toggle-product-slug-modification', 'enabled' => '#sylius_product_enabled', ], diff --git a/src/Sylius/Behat/Page/Admin/ProductAttribute/CreatePage.php b/src/Sylius/Behat/Page/Admin/ProductAttribute/CreatePage.php index d34285947a7..3bdf7d90258 100644 --- a/src/Sylius/Behat/Page/Admin/ProductAttribute/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductAttribute/CreatePage.php @@ -25,7 +25,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface public function nameIt(string $name, string $language): void { - $this->getDocument()->fillField(sprintf('sylius_product_attribute_translations_%s_name', $language), $name); + $this->getDocument()->fillField(sprintf('sylius_admin_product_attribute_translations_%s_name', $language), $name); } public function isTypeDisabled(): bool @@ -80,14 +80,14 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'attribute_choice_list' => 'div[data-form-collection="list"]', - 'attribute_choice_list_element' => '#sylius_product_attribute_configuration_choices_%index%_%localeCode%', - 'code' => '#sylius_product_attribute_code', - 'max' => '#sylius_product_attribute_configuration_max', - 'min' => '#sylius_product_attribute_configuration_min', - 'multiple' => 'label[for=sylius_product_attribute_configuration_multiple]', - 'name' => '#sylius_product_attribute_translations_en_US_name', - 'type' => '#sylius_product_attribute_type', - 'translation' => '#sylius_product_attribute_translatable', + 'attribute_choice_list_element' => '#sylius_admin_product_attribute_configuration_choices_%index%_%localeCode%', + 'code' => '#sylius_admin_product_attribute_code', + 'max' => '#sylius_admin_product_attribute_configuration_max', + 'min' => '#sylius_admin_product_attribute_configuration_min', + 'multiple' => 'label[for=sylius_admin_product_attribute_configuration_multiple]', + 'name' => '#sylius_admin_product_attribute_translations_en_US_name', + 'type' => '#sylius_admin_product_attribute_type', + 'translation' => '#sylius_admin_product_attribute_translatable', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ProductAttribute/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ProductAttribute/UpdatePage.php index d5c2bd84b8d..33b09dae3ad 100644 --- a/src/Sylius/Behat/Page/Admin/ProductAttribute/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductAttribute/UpdatePage.php @@ -24,7 +24,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface public function changeName(string $name, string $language): void { - $this->getDocument()->fillField(sprintf('sylius_product_attribute_translations_%s_name', $language), $name); + $this->getDocument()->fillField(sprintf('sylius_admin_product_attribute_translations_%s_name', $language), $name); } public function isTypeDisabled(): bool @@ -70,10 +70,10 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'attribute_choice_list_element' => 'input[value="%value%"]', - 'attribute_choices' => '#sylius_product_attribute_configuration_choices', - 'code' => '#sylius_product_attribute_code', - 'type' => '#sylius_product_attribute_type', - 'name' => '#sylius_product_attribute_translations_en_US_name', + 'attribute_choices' => '#sylius_admin_product_attribute_configuration_choices', + 'code' => '#sylius_admin_product_attribute_code', + 'type' => '#sylius_admin_product_attribute_type', + 'name' => '#sylius_admin_product_attribute_translations_en_US_name', ]); } diff --git a/src/Sylius/Behat/Page/Admin/ProductOption/CreatePage.php b/src/Sylius/Behat/Page/Admin/ProductOption/CreatePage.php index 0a96852cfc5..b175f9ada09 100644 --- a/src/Sylius/Behat/Page/Admin/ProductOption/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductOption/CreatePage.php @@ -26,7 +26,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface public function nameItIn(string $name, string $language): void { $this->getDocument()->fillField( - sprintf('sylius_product_option_translations_%s_name', $language), + sprintf('sylius_admin_product_option_translations_%s_name', $language), $name, ); } @@ -54,9 +54,9 @@ public function checkValidationMessageForOptionValues(string $message): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_product_option_code', - 'name' => '#sylius_product_option_translations_en_US_name', - 'values' => '#sylius_product_option_values', + 'code' => '#sylius_admin_product_option_code', + 'name' => '#sylius_admin_product_option_translations_en_US_name', + 'values' => '#sylius_admin_product_option_values', 'values_validation' => '.ui.segment', ]); } diff --git a/src/Sylius/Behat/Page/Admin/ProductOption/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ProductOption/UpdatePage.php index 1f917522a5a..cab3676aa50 100644 --- a/src/Sylius/Behat/Page/Admin/ProductOption/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductOption/UpdatePage.php @@ -25,7 +25,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface public function nameItIn(string $name, string $language): void { $this->getDocument()->fillField( - sprintf('sylius_product_option_translations_%s_name', $language), + sprintf('sylius_admin_product_option_translations_%s_name', $language), $name, ); } @@ -71,9 +71,9 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_product_option_code', - 'name' => '#sylius_product_option_translations_en_US_name', - 'values' => '#sylius_product_option_values', + 'code' => '#sylius_admin_product_option_code', + 'name' => '#sylius_admin_product_option_translations_en_US_name', + 'values' => '#sylius_admin_product_option_values', ]); } diff --git a/src/Sylius/Behat/Page/Admin/ProductReview/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ProductReview/UpdatePage.php index 7d21e238a8a..0cba6cc817a 100644 --- a/src/Sylius/Behat/Page/Admin/ProductReview/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductReview/UpdatePage.php @@ -53,11 +53,11 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'checked_rating' => 'input[checked="checked"]', - 'comment' => '#sylius_product_review_comment', - 'rating' => '#sylius_product_review_rating_%position%', + 'comment' => '#sylius_admin_product_review_comment', + 'rating' => '#sylius_admin_product_review_rating_%position%', 'customer_name' => '.sylius-customer-name', 'product_name' => '.sylius-product-name', - 'title' => '#sylius_product_review_title', + 'title' => '#sylius_admin_product_review_title', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/CreatePage.php b/src/Sylius/Behat/Page/Admin/ProductVariant/CreatePage.php index 29c6bfe687f..2f55383abff 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/CreatePage.php @@ -53,7 +53,7 @@ public function specifyHeightWidthDepthAndWeight(string $height, string $width, public function nameItIn(string $name, string $language): void { $this->getDocument()->fillField( - sprintf('sylius_product_variant_translations_%s_name', $language), + sprintf('sylius_admin_product_variant_translations_%s_name', $language), $name, ); } @@ -104,21 +104,21 @@ public function setShippingRequired(bool $isShippingRequired): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_product_variant_code', - 'depth' => '#sylius_product_variant_depth', - 'form' => 'form[name="sylius_product_variant"]', - 'height' => '#sylius_product_variant_height', - 'minimum_price' => '#sylius_product_variant_channelPricings_%channelCode%_minimumPrice', - 'on_hand' => '#sylius_product_variant_onHand', - 'option_select' => '#sylius_product_variant_optionValues_%option-name%', - 'price_calculator' => '#sylius_product_variant_pricingCalculator', - 'shipping_category' => '#sylius_product_variant_shippingCategory', - 'shipping_required' => '#sylius_product_variant_shippingRequired', - 'original_price' => '#sylius_product_variant_channelPricings_%channelCode%_originalPrice', - 'price' => '#sylius_product_variant_channelPricings_%channelCode%_price', + 'code' => '#sylius_admin_product_variant_code', + 'depth' => '#sylius_admin_product_variant_depth', + 'form' => 'form[name="sylius_admin_product_variant"]', + 'height' => '#sylius_admin_product_variant_height', + 'minimum_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_minimumPrice', + 'on_hand' => '#sylius_admin_product_variant_onHand', + 'option_select' => '#sylius_admin_product_variant_optionValues_%option-name%', + 'price_calculator' => '#sylius_admin_product_variant_pricingCalculator', + 'shipping_category' => '#sylius_admin_product_variant_shippingCategory', + 'shipping_required' => '#sylius_admin_product_variant_shippingRequired', + 'original_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_originalPrice', + 'price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_price', 'prices-body' => '[data-test-product-channel-pricings-accordion-body]', - 'weight' => '#sylius_product_variant_weight', - 'width' => '#sylius_product_variant_width', + 'weight' => '#sylius_admin_product_variant_weight', + 'width' => '#sylius_admin_product_variant_width', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/GeneratePage.php b/src/Sylius/Behat/Page/Admin/ProductVariant/GeneratePage.php index 344d7575fbe..a8cf5a9b3a1 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/GeneratePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/GeneratePage.php @@ -79,9 +79,9 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'generate_button' => '[data-test-generate-button]', - 'delete_button' => '#sylius_product_generate_variants_variants_%position% [data-test-delete-button]', - 'code' => '#sylius_product_generate_variants_variants_%position% [data-test-code]', - 'channel_pricings' => '#sylius_product_generate_variants_variants_%position% [data-test-channel-pricings]', + 'delete_button' => '#sylius_admin_product_generate_variants_variants_%position% [data-test-delete-button]', + 'code' => '#sylius_admin_product_generate_variants_variants_%position% [data-test-code]', + 'channel_pricings' => '#sylius_admin_product_generate_variants_variants_%position% [data-test-channel-pricings]', 'form' => '[data-live-name-value="sylius_admin:product:generate_product_variants_form"]', ]); } diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php index ccc78bbad60..51bb6471107 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php @@ -130,19 +130,19 @@ public function isShippingRequired(): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_product_variant_code', - 'minimum_price' => '#sylius_product_variant_channelPricings_%channelCode%_minimumPrice', - 'name' => '#sylius_product_variant_translations_%language%_name', - 'on_hand' => '#sylius_product_variant_onHand', - 'option_values' => '#sylius_product_variant_optionValues_%optionName%', - 'original_price' => '#sylius_product_variant_channelPricings_%channelCode%_originalPrice', - 'price' => '#sylius_product_variant_channelPricings_%channelCode%_price', + 'code' => '#sylius_admin_product_variant_code', + 'minimum_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_minimumPrice', + 'name' => '#sylius_admin_product_variant_translations_%language%_name', + 'on_hand' => '#sylius_admin_product_variant_onHand', + 'option_values' => '#sylius_admin_product_variant_optionValues_%optionName%', + 'original_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_originalPrice', + 'price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_price', 'pricing_configuration' => '#sylius_calculator_container', - 'shipping_required' => '#sylius_product_variant_shippingRequired', + 'shipping_required' => '#sylius_admin_product_variant_shippingRequired', 'show_product_dropdown' => '.scrolling.menu', 'show_product_single_button' => 'a:contains("Show product in shop page")', - 'tracked' => '#sylius_product_variant_tracked', - 'enabled' => '#sylius_product_variant_enabled', + 'tracked' => '#sylius_admin_product_variant_tracked', + 'enabled' => '#sylius_admin_product_variant_enabled', ]); } diff --git a/src/Sylius/Behat/Page/Admin/Promotion/CreatePage.php b/src/Sylius/Behat/Page/Admin/Promotion/CreatePage.php index 4c735f29702..b6e76415fea 100644 --- a/src/Sylius/Behat/Page/Admin/Promotion/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Promotion/CreatePage.php @@ -42,9 +42,9 @@ public function getValidationMessage(string $element): string protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_promotion_code', + 'code' => '#sylius_admin_promotion_code', 'form' => '[data-live-name-value="sylius_admin:promotion:form"]', - 'rules' => '#sylius_promotion_rules', + 'rules' => '#sylius_admin_promotion_rules', ]); } diff --git a/src/Sylius/Behat/Page/Admin/Promotion/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Promotion/UpdatePage.php index ec46e6cf4ef..5d86a93c148 100644 --- a/src/Sylius/Behat/Page/Admin/Promotion/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Promotion/UpdatePage.php @@ -128,24 +128,24 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'action_field' => '[id^="sylius_promotion_actions_"][id$="_configuration_%channelCode%_%field%"]', + 'action_field' => '[id^="sylius_admin_promotion_actions_"][id$="_configuration_%channelCode%_%field%"]', 'actions' => '#actions', - 'applies_to_discounted' => '#sylius_promotion_appliesToDiscounted', - 'code' => '#sylius_promotion_code', - 'ends_at' => '#sylius_promotion_endsAt', - 'ends_at_date' => '#sylius_promotion_endsAt_date', - 'ends_at_time' => '#sylius_promotion_endsAt_time', - 'exclusive' => '#sylius_promotion_exclusive', - 'coupon_based' => '#sylius_promotion_couponBased', - 'name' => '#sylius_promotion_name', - 'order_percentage_action_field' => '[id^="sylius_promotion_actions_"][id$="_configuration_percentage"]', - 'priority' => '#sylius_promotion_priority', - 'rule_amount' => '[id^="sylius_promotion_rules_"][id$="_configuration_%channelCode%_amount"]', + 'applies_to_discounted' => '#sylius_admin_promotion_appliesToDiscounted', + 'code' => '#sylius_admin_promotion_code', + 'ends_at' => '#sylius_admin_promotion_endsAt', + 'ends_at_date' => '#sylius_admin_promotion_endsAt_date', + 'ends_at_time' => '#sylius_admin_promotion_endsAt_time', + 'exclusive' => '#sylius_admin_promotion_exclusive', + 'coupon_based' => '#sylius_admin_promotion_couponBased', + 'name' => '#sylius_admin_promotion_name', + 'order_percentage_action_field' => '[id^="sylius_admin_promotion_actions_"][id$="_configuration_percentage"]', + 'priority' => '#sylius_admin_promotion_priority', + 'rule_amount' => '[id^="sylius_admin_promotion_rules_"][id$="_configuration_%channelCode%_amount"]', 'rules' => '#rules', - 'usage_limit' => '#sylius_promotion_usageLimit', - 'starts_at' => '#sylius_promotion_startsAt', - 'starts_at_date' => '#sylius_promotion_startsAt_date', - 'starts_at_time' => '#sylius_promotion_startsAt_time', + 'usage_limit' => '#sylius_admin_promotion_usageLimit', + 'starts_at' => '#sylius_admin_promotion_startsAt', + 'starts_at_date' => '#sylius_admin_promotion_startsAt_date', + 'starts_at_time' => '#sylius_admin_promotion_startsAt_time', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/PromotionCoupon/CreatePage.php b/src/Sylius/Behat/Page/Admin/PromotionCoupon/CreatePage.php index 3cca12681ef..9769078a0e0 100644 --- a/src/Sylius/Behat/Page/Admin/PromotionCoupon/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/PromotionCoupon/CreatePage.php @@ -40,10 +40,10 @@ public function setUsageLimit(int $limit): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_promotion_coupon_code', - 'expires_at' => '#sylius_promotion_coupon_expiresAt', - 'usage_limit' => '#sylius_promotion_coupon_usageLimit', - 'per_customer_usage_limit' => '#sylius_promotion_coupon_perCustomerUsageLimit', + 'code' => '#sylius_admin_promotion_coupon_code', + 'expires_at' => '#sylius_admin_promotion_coupon_expiresAt', + 'usage_limit' => '#sylius_admin_promotion_coupon_usageLimit', + 'per_customer_usage_limit' => '#sylius_admin_promotion_coupon_perCustomerUsageLimit', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/PromotionCoupon/UpdatePage.php b/src/Sylius/Behat/Page/Admin/PromotionCoupon/UpdatePage.php index 3cc55455401..2c04debbafa 100644 --- a/src/Sylius/Behat/Page/Admin/PromotionCoupon/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/PromotionCoupon/UpdatePage.php @@ -61,11 +61,11 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_promotion_coupon_code', - 'expires_at' => '#sylius_promotion_coupon_expiresAt', - 'usage_limit' => '#sylius_promotion_coupon_usageLimit', - 'per_customer_usage_limit' => '#sylius_promotion_coupon_perCustomerUsageLimit', - 'reusable_from_cancelled_orders' => '#sylius_promotion_coupon_reusableFromCancelledOrders', + 'code' => '#sylius_admin_promotion_coupon_code', + 'expires_at' => '#sylius_admin_promotion_coupon_expiresAt', + 'usage_limit' => '#sylius_admin_promotion_coupon_usageLimit', + 'per_customer_usage_limit' => '#sylius_admin_promotion_coupon_perCustomerUsageLimit', + 'reusable_from_cancelled_orders' => '#sylius_admin_promotion_coupon_reusableFromCancelledOrders', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Shipment/IndexPage.php b/src/Sylius/Behat/Page/Admin/Shipment/IndexPage.php index b3209187cba..cf2b6acba0b 100644 --- a/src/Sylius/Behat/Page/Admin/Shipment/IndexPage.php +++ b/src/Sylius/Behat/Page/Admin/Shipment/IndexPage.php @@ -63,7 +63,7 @@ public function shipShipmentOfOrderWithTrackingCode(string $orderNumber, string /** @var NodeElement $actions */ $actions = $this->getField($orderNumber, 'actions'); - $actions->fillField('sylius_shipment_ship_tracking', $trackingCode); + $actions->fillField('sylius_admin_shipment_ship_tracking', $trackingCode); $actions->pressButton('Ship'); } diff --git a/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePage.php b/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePage.php index 412e7b3e783..f4936944c18 100644 --- a/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/ShippingCategory/CreatePage.php @@ -30,8 +30,8 @@ public function specifyDescription(string $description): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_shipping_category_code', - 'description' => '#sylius_shipping_category_description', + 'code' => '#sylius_admin_shipping_category_code', + 'description' => '#sylius_admin_shipping_category_description', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php index b480d702729..89098c74b13 100644 --- a/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ShippingCategory/UpdatePage.php @@ -29,8 +29,8 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_shipping_category_code', - 'name' => '#sylius_shipping_category_name', + 'code' => '#sylius_admin_shipping_category_code', + 'name' => '#sylius_admin_shipping_category_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/TaxCategory/CreatePage.php b/src/Sylius/Behat/Page/Admin/TaxCategory/CreatePage.php index 6acbbb575cc..ee50bc6667e 100644 --- a/src/Sylius/Behat/Page/Admin/TaxCategory/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/TaxCategory/CreatePage.php @@ -27,8 +27,8 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_tax_category_code', - 'name' => '#sylius_tax_category_name', + 'code' => '#sylius_admin_tax_category_code', + 'name' => '#sylius_admin_tax_category_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/TaxCategory/UpdatePage.php b/src/Sylius/Behat/Page/Admin/TaxCategory/UpdatePage.php index 6ab43f01b86..f20c7be3715 100644 --- a/src/Sylius/Behat/Page/Admin/TaxCategory/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/TaxCategory/UpdatePage.php @@ -31,9 +31,9 @@ protected function getCodeElement(): NodeElement protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'code' => '#sylius_tax_category_code', - 'description' => '#sylius_tax_category_description', - 'name' => '#sylius_tax_category_name', + 'code' => '#sylius_admin_tax_category_code', + 'description' => '#sylius_admin_tax_category_description', + 'name' => '#sylius_admin_tax_category_name', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/TaxRate/FormAwareTrait.php b/src/Sylius/Behat/Page/Admin/TaxRate/FormAwareTrait.php index 8f8486c12fc..69d9a91bed3 100644 --- a/src/Sylius/Behat/Page/Admin/TaxRate/FormAwareTrait.php +++ b/src/Sylius/Behat/Page/Admin/TaxRate/FormAwareTrait.php @@ -59,17 +59,17 @@ public function specifyEndDate(\DateTimeInterface $endDate): void protected function getDefinedFormElements(): array { return [ - 'field_amount' => '#sylius_tax_rate_amount', - 'field_calculator' => '#sylius_tax_rate_calculator', - 'field_category' => '#sylius_tax_rate_category', - 'field_code' => '#sylius_tax_rate_code', - 'field_end_date' => '#sylius_tax_rate_endDate_date', - 'field_end_date_time' => '#sylius_tax_rate_endDate_time', - 'field_included_in_price' => '#sylius_tax_rate_includedInPrice', - 'field_name' => '#sylius_tax_rate_name', - 'field_start_date' => '#sylius_tax_rate_startDate_date', - 'field_start_date_time' => '#sylius_tax_rate_startDate_time', - 'field_zone' => '#sylius_tax_rate_zone', + 'field_amount' => '#sylius_admin_tax_rate_amount', + 'field_calculator' => '#sylius_admin_tax_rate_calculator', + 'field_category' => '#sylius_admin_tax_rate_category', + 'field_code' => '#sylius_admin_tax_rate_code', + 'field_end_date' => '#sylius_admin_tax_rate_endDate_date', + 'field_end_date_time' => '#sylius_admin_tax_rate_endDate_time', + 'field_included_in_price' => '#sylius_admin_tax_rate_includedInPrice', + 'field_name' => '#sylius_admin_tax_rate_name', + 'field_start_date' => '#sylius_admin_tax_rate_startDate_date', + 'field_start_date_time' => '#sylius_admin_tax_rate_startDate_time', + 'field_zone' => '#sylius_admin_tax_rate_zone', ]; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/AddressTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/AddressTypeExtension.php deleted file mode 100644 index 860e08977ee..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/AddressTypeExtension.php +++ /dev/null @@ -1,92 +0,0 @@ - $countryRepository - */ - public function __construct(private readonly CountryRepositoryInterface $countryRepository) - { - } - - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder = new DynamicFormBuilder($builder); - - $builder - ->addDependent('provinceCode', 'countryCode', function (DependentField $field, ?string $countryCode = null) { - if (null === $countryCode) { - return; - } - - $country = $this->countryRepository->findOneBy(['code' => $countryCode]); - - if ($country->hasProvinces()) { - $field->add(ProvinceCodeChoiceType::class, [ - 'country' => $country, - 'placeholder' => 'sylius.form.province.select', - 'label' => 'sylius.form.address.province', - 'auto_initialize' => false, - ]); - } - }) - ->addDependent('provinceName', 'countryCode', function (DependentField $field, ?string $countryCode = null) { - if (null === $countryCode) { - return; - } - - $country = $this->countryRepository->findOneBy(['code' => $countryCode]); - - if (!$country->hasProvinces()) { - $field->add(TextType::class, [ - 'label' => 'sylius.form.address.province', - 'required' => false, - 'auto_initialize' => false, - ]); - } - }); - - $builder->addEventListener( - FormEvents::SUBMIT, - function (FormEvent $formEvent) { - /** @var AddressInterface $data */ - $data = $formEvent->getData(); - $form = $formEvent->getForm(); - - $form->has('provinceCode') ?: $data->setProvinceCode(null); - $form->has('provinceName') ?: $data->setProvinceName(null); - }, - ); - } - - public static function getExtendedTypes(): iterable - { - return [AddressType::class]; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionActionTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionActionTypeExtension.php deleted file mode 100644 index a88bc300643..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionActionTypeExtension.php +++ /dev/null @@ -1,42 +0,0 @@ -add('type', HiddenType::class); - } - - public static function getExtendedTypes(): iterable - { - yield BaseCatalogPromotionActionType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScopeTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScopeTypeExtension.php deleted file mode 100644 index 6dfd78b8219..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScopeTypeExtension.php +++ /dev/null @@ -1,42 +0,0 @@ -add('type', HiddenType::class); - } - - public static function getExtendedTypes(): iterable - { - yield BaseCatalogPromotionScopeType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionTypeExtension.php deleted file mode 100644 index 9479f574130..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionTypeExtension.php +++ /dev/null @@ -1,76 +0,0 @@ - $scopeTypes - * @param array $actionTypes - */ - public function __construct( - private readonly array $scopeTypes, - private readonly array $actionTypes, - ) { - } - - /** @param array $options */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('scopes', LiveCollectionType::class, [ - 'entry_type' => CatalogPromotionScopeType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'button_add_type' => AddButtonType::class, - 'button_add_options' => [ - 'label' => 'sylius.ui.add_scope', - 'types' => $this->scopeTypes, - ], - 'button_delete_options' => [ - 'label' => false, - ], - ]) - ->add('actions', LiveCollectionType::class, [ - 'entry_type' => CatalogPromotionActionType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'button_add_type' => AddButtonType::class, - 'button_add_options' => [ - 'label' => 'sylius.ui.add_action', - 'types' => $this->actionTypes, - ], - 'button_delete_options' => [ - 'label' => false, - ], - ]) - ; - } - - /** @return iterable */ - public static function getExtendedTypes(): iterable - { - yield CatalogPromotionType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelTypeExtension.php deleted file mode 100644 index 2f36d96ae5a..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelTypeExtension.php +++ /dev/null @@ -1,37 +0,0 @@ -add('menuTaxon', TaxonAutocompleteType::class, [ - 'label' => 'sylius.form.channel.menu_taxon', - 'multiple' => false, - ]) - ; - } - - public static function getExtendedTypes(): iterable - { - yield ChannelType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CountryTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/CountryTypeExtension.php deleted file mode 100644 index a7227d08395..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CountryTypeExtension.php +++ /dev/null @@ -1,95 +0,0 @@ - $countryRepository */ - public function __construct(private readonly RepositoryInterface $countryRepository) - { - } - - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { - $options = [ - 'label' => 'sylius.form.country.name', - 'choice_loader' => null, - ]; - - $country = $event->getData(); - if ($country instanceof CountryInterface && null !== $country->getCode()) { - $options['disabled'] = true; - $options['choices'] = [$this->getCountryName($country->getCode()) => $country->getCode()]; - } else { - $options['choices'] = array_flip($this->getAvailableCountries()); - } - - $form = $event->getForm(); - $form->add('code', \Symfony\Component\Form\Extension\Core\Type\CountryType::class, $options); - }); - - $builder - ->add('provinces', LiveCollectionType::class, [ - 'entry_type' => ProvinceType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'button_add_options' => [ - 'label' => 'sylius.form.country.add_province', - ], - ]) - ->add('enabled', CheckboxType::class, [ - 'label' => 'sylius.form.country.enabled', - ]) - ; - } - - public static function getExtendedTypes(): iterable - { - return [CountryType::class]; - } - - private function getCountryName(string $code): string - { - return Countries::getName($code); - } - - /** @return string[] */ - private function getAvailableCountries(): array - { - $availableCountries = Countries::getNames(); - - /** @var CountryInterface[] $definedCountries */ - $definedCountries = $this->countryRepository->findAll(); - - foreach ($definedCountries as $country) { - unset($availableCountries[$country->getCode()]); - } - - return $availableCountries; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductGenerateVariantsTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductGenerateVariantsTypeExtension.php deleted file mode 100644 index 16f67d17db8..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductGenerateVariantsTypeExtension.php +++ /dev/null @@ -1,44 +0,0 @@ -add('variants', LiveCollectionType::class, [ - 'entry_type' => ProductVariantGenerationType::class, - 'allow_add' => false, - 'allow_delete' => true, - 'by_reference' => false, - 'label' => false, - 'button_delete_options' => [ - 'label' => false, - ], - ]) - ; - } - - public static function getExtendedTypes(): iterable - { - yield ProductGenerateVariantsType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductTypeExtension.php deleted file mode 100644 index 37a424983c2..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductTypeExtension.php +++ /dev/null @@ -1,53 +0,0 @@ - $options - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('images', LiveCollectionType::class, [ - 'entry_type' => ProductImageType::class, - 'entry_options' => ['product' => $options['data']], - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'label' => 'sylius.form.product.images', - 'block_name' => 'entry', - ]) - ->add('associations', ProductAssociationsType::class, [ - 'label' => false, - ]) - ; - } - - /** - * @return iterable - */ - public static function getExtendedTypes(): iterable - { - return [ProductType::class]; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodTypeExtension.php deleted file mode 100644 index 17a31d61f2d..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodTypeExtension.php +++ /dev/null @@ -1,61 +0,0 @@ - $types */ - public function __construct(private readonly array $types) - { - } - - /** - * @param array $options - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('rules', LiveCollectionType::class, [ - 'entry_type' => ShippingMethodRuleType::class, - 'entry_options' => [ - 'types' => $this->types, - ], - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'button_add_type' => AddButtonType::class, - 'button_add_options' => [ - 'label' => 'sylius.ui.add_rule', - 'types' => $this->types, - ], - 'button_delete_options' => [ - 'label' => false, - ], - ]) - ; - } - - /** @return iterable */ - public static function getExtendedTypes(): iterable - { - yield ShippingMethodType::class; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ZoneTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Extension/ZoneTypeExtension.php deleted file mode 100644 index c84aa390f16..00000000000 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ZoneTypeExtension.php +++ /dev/null @@ -1,49 +0,0 @@ -addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { - $entryOptions = $event->getForm()->get('members')->getConfig()->getOptions()['entry_options']; - - $event->getForm()->add('members', LiveCollectionType::class, [ - 'entry_type' => ZoneMemberType::class, - 'entry_options' => $entryOptions, - 'button_add_options' => [ - 'label' => 'sylius.form.zone.add_member', - ], - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'delete_empty' => true, - ]); - }); - } - - public static function getExtendedTypes(): iterable - { - return [ZoneType::class]; - } -} diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/AddressType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/AddressType.php index 5c18f15fe41..3013703c683 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/AddressType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/AddressType.php @@ -14,17 +14,85 @@ namespace Sylius\Bundle\AdminBundle\Form\Type; use Sylius\Bundle\AddressingBundle\Form\Type\AddressType as BaseAddressType; +use Sylius\Bundle\AddressingBundle\Form\Type\ProvinceCodeChoiceType; +use Sylius\Component\Addressing\Model\CountryInterface; +use Sylius\Component\Addressing\Repository\CountryRepositoryInterface; +use Sylius\Component\Core\Model\AddressInterface; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; +use Symfonycasts\DynamicForms\DependentField; +use Symfonycasts\DynamicForms\DynamicFormBuilder; final class AddressType extends AbstractType { - public function getBlockPrefix(): string + /** + * @param CountryRepositoryInterface $countryRepository + */ + public function __construct(private readonly CountryRepositoryInterface $countryRepository) { - return 'sylius_admin_address'; + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder = new DynamicFormBuilder($builder); + + $builder + ->addDependent('provinceCode', 'countryCode', function (DependentField $field, ?string $countryCode = null) { + if (null === $countryCode) { + return; + } + + $country = $this->countryRepository->findOneBy(['code' => $countryCode]); + + if ($country->hasProvinces()) { + $field->add(ProvinceCodeChoiceType::class, [ + 'country' => $country, + 'placeholder' => 'sylius.form.province.select', + 'label' => 'sylius.form.address.province', + 'auto_initialize' => false, + ]); + } + }) + ->addDependent('provinceName', 'countryCode', function (DependentField $field, ?string $countryCode = null) { + if (null === $countryCode) { + return; + } + + $country = $this->countryRepository->findOneBy(['code' => $countryCode]); + + if (!$country->hasProvinces()) { + $field->add(TextType::class, [ + 'label' => 'sylius.form.address.province', + 'required' => false, + 'auto_initialize' => false, + ]); + } + }) + ; + + $builder->addEventListener( + FormEvents::SUBMIT, + function (FormEvent $formEvent) { + /** @var AddressInterface $data */ + $data = $formEvent->getData(); + $form = $formEvent->getForm(); + + $form->has('provinceCode') ?: $data->setProvinceCode(null); + $form->has('provinceName') ?: $data->setProvinceName(null); + }, + ); } public function getParent(): string { return BaseAddressType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_address'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionActionType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionActionType.php index e19dd9bcc43..f3902f51b82 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionActionType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionActionType.php @@ -15,58 +15,23 @@ use Sylius\Bundle\PromotionBundle\Form\Type\CatalogPromotionActionType as BaseCatalogPromotionActionType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; -use Twig\Environment; final class CatalogPromotionActionType extends AbstractType { - /** @var array */ - private array $actionTypes = []; - - /** @var array */ - private array $actionConfigurationTypes; - - /** - * @param iterable $actionConfigurationTypes - */ - public function __construct(iterable $actionConfigurationTypes, private Environment $twig) + public function buildForm(FormBuilderInterface $builder, array $options): void { - foreach ($actionConfigurationTypes as $type => $formType) { - $this->actionConfigurationTypes[$type] = $formType::class; - $this->actionTypes['sylius.form.catalog_promotion.action.' . $type] = $type; - } + $builder->add('type', HiddenType::class); } - public function buildForm(FormBuilderInterface $builder, array $options): void + public function getParent(): string { - $builder - ->add('type', ChoiceType::class, [ - 'label' => 'sylius.ui.type', - 'choices' => $this->actionTypes, - 'choice_attr' => function (?string $type) use ($builder): array { - return [ - 'data-configuration' => $this->twig->render( - '@SyliusAdmin/CatalogPromotion/_action.html.twig', - ['field' => $builder->create( - 'configuration', - $this->actionConfigurationTypes[$type], - ['label' => false, 'csrf_protection' => false], - )->getForm()->createView()], - ), - ]; - }, - ]) - ; + return BaseCatalogPromotionActionType::class; } public function getBlockPrefix(): string { return 'sylius_admin_catalog_promotion_action'; } - - public function getParent(): string - { - return BaseCatalogPromotionActionType::class; - } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForProductsScopeConfigurationTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForProductsScopeConfigurationType.php similarity index 70% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForProductsScopeConfigurationTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForProductsScopeConfigurationType.php index 5c47a4de2bb..dd031cd7c15 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForProductsScopeConfigurationTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForProductsScopeConfigurationType.php @@ -11,16 +11,16 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension\CatalogPromotionScope; +namespace Sylius\Bundle\AdminBundle\Form\Type\CatalogPromotionScope; use Sylius\Bundle\AdminBundle\Form\Type\ProductAutocompleteType; -use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForProductsScopeConfigurationType; +use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForProductsScopeConfigurationType as BaseForProductsScopeConfigurationType; use Sylius\Component\Core\Model\ProductInterface; -use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\FormBuilderInterface; -final class ForProductsScopeConfigurationTypeExtension extends AbstractTypeExtension +final class ForProductsScopeConfigurationType extends AbstractType { /** @param DataTransformerInterface $productsToCodesTransformer */ public function __construct(private readonly DataTransformerInterface $productsToCodesTransformer) @@ -38,8 +38,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ; } - public static function getExtendedTypes(): iterable + public function getParent(): string { - yield ForProductsScopeConfigurationType::class; + return BaseForProductsScopeConfigurationType::class; + } + + public function getBlockPrefix(): string + { + return 'sylius_catalog_promotion_scope_for_products_configuration'; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForTaxonsScopeConfigurationTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForTaxonsScopeConfigurationType.php similarity index 70% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForTaxonsScopeConfigurationTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForTaxonsScopeConfigurationType.php index 84ea2b24beb..4810a8776a3 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForTaxonsScopeConfigurationTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForTaxonsScopeConfigurationType.php @@ -11,16 +11,16 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension\CatalogPromotionScope; +namespace Sylius\Bundle\AdminBundle\Form\Type\CatalogPromotionScope; use Sylius\Bundle\AdminBundle\Form\Type\TaxonAutocompleteType; -use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForTaxonsScopeConfigurationType; +use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForTaxonsScopeConfigurationType as BaseForTaxonsScopeConfigurationType; use Sylius\Component\Core\Model\TaxonInterface; -use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\FormBuilderInterface; -final class ForTaxonsScopeConfigurationTypeExtension extends AbstractTypeExtension +final class ForTaxonsScopeConfigurationType extends AbstractType { /** @param DataTransformerInterface $taxonsToCodesTransformer */ public function __construct(private readonly DataTransformerInterface $taxonsToCodesTransformer) @@ -38,8 +38,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ; } - public static function getExtendedTypes(): iterable + public function getParent(): string { - yield ForTaxonsScopeConfigurationType::class; + return BaseForTaxonsScopeConfigurationType::class; + } + + public function getBlockPrefix(): string + { + return 'sylius_admin_catalog_promotion_scope_taxon_configuration'; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForVariantsScopeConfigurationTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForVariantsScopeConfigurationType.php similarity index 71% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForVariantsScopeConfigurationTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForVariantsScopeConfigurationType.php index 55429957679..4c295e63eff 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/CatalogPromotionScope/ForVariantsScopeConfigurationTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScope/ForVariantsScopeConfigurationType.php @@ -11,16 +11,16 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension\CatalogPromotionScope; +namespace Sylius\Bundle\AdminBundle\Form\Type\CatalogPromotionScope; use Sylius\Bundle\AdminBundle\Form\Type\ProductVariantAutocompleteType; -use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForVariantsScopeConfigurationType; +use Sylius\Bundle\CoreBundle\Form\Type\CatalogPromotionScope\ForVariantsScopeConfigurationType as BaseForVariantsScopeConfigurationType; use Sylius\Component\Core\Model\ProductVariantInterface; -use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\FormBuilderInterface; -final class ForVariantsScopeConfigurationTypeExtension extends AbstractTypeExtension +final class ForVariantsScopeConfigurationType extends AbstractType { /** @param DataTransformerInterface $productVariantsToCodesTransformer */ public function __construct(private readonly DataTransformerInterface $productVariantsToCodesTransformer) @@ -38,8 +38,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ; } - public static function getExtendedTypes(): iterable + public function getParent(): string { - yield ForVariantsScopeConfigurationType::class; + return BaseForVariantsScopeConfigurationType::class; + } + + public function getBlockPrefix(): string + { + return 'sylius_admin_catalog_promotion_scope_variant_configuration'; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScopeType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScopeType.php index 8c0f77fd073..a1caee1260c 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScopeType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionScopeType.php @@ -14,55 +14,62 @@ namespace Sylius\Bundle\AdminBundle\Form\Type; use Sylius\Bundle\PromotionBundle\Form\Type\CatalogPromotionScopeType as BaseCatalogPromotionScopeType; +use Sylius\Component\Promotion\Model\CatalogPromotionScopeInterface; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; -use Twig\Environment; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; final class CatalogPromotionScopeType extends AbstractType { - /** @var array */ - private array $scopeTypes = []; - /** @var array */ private array $scopeConfigurationTypes; /** * @param iterable $scopeConfigurationTypes */ - public function __construct(iterable $scopeConfigurationTypes, private Environment $twig) + public function __construct(iterable $scopeConfigurationTypes) { foreach ($scopeConfigurationTypes as $type => $formType) { $this->scopeConfigurationTypes[$type] = $formType::class; - $this->scopeTypes['sylius.form.catalog_promotion.scope.' . $type] = $type; } } public function buildForm(FormBuilderInterface $builder, array $options): void { + $builder->add('type', HiddenType::class); + $builder - ->add('type', ChoiceType::class, [ - 'label' => 'sylius.ui.type', - 'choices' => $this->scopeTypes, - 'choice_attr' => function (?string $type) use ($builder): array { - return [ - 'data-configuration' => $this->twig->render( - '@SyliusAdmin/CatalogPromotion/Scope/' . $type . '.html.twig', - ['field' => $builder->create('configuration', $this->scopeConfigurationTypes[$type])->getForm()->createView()], - ), - ]; - }, - ]) + ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { + $this->addScopeToForm($event); + }) + ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void { + $this->addScopeToForm($event); + }) ; } + public function getParent(): string + { + return BaseCatalogPromotionScopeType::class; + } + public function getBlockPrefix(): string { return 'sylius_admin_catalog_promotion_scope'; } - public function getParent(): string + private function addScopeToForm(FormEvent $event): void { - return BaseCatalogPromotionScopeType::class; + $data = $event->getData(); + if ($data === null) { + return; + } + $dataType = $data instanceof CatalogPromotionScopeInterface ? $data->getType() : $data['type']; + $scopeConfigurationType = $this->scopeConfigurationTypes[$dataType]; + + $form = $event->getForm(); + $form->add('configuration', $scopeConfigurationType); } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionType.php index 7cf9ad7bf5e..84f98d60343 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CatalogPromotionType.php @@ -15,38 +15,63 @@ use Sylius\Bundle\PromotionBundle\Form\Type\CatalogPromotionType as BaseCatalogPromotionType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class CatalogPromotionType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder->add('scopes', CollectionType::class, [ - 'label' => 'sylius.ui.scopes', - 'entry_type' => CatalogPromotionScopeType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'required' => false, - ]) - ->add('actions', CollectionType::class, [ - 'label' => 'sylius.ui.actions', - 'entry_type' => CatalogPromotionActionType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'by_reference' => false, - 'required' => false, - ]); + /** + * @param array $scopeTypes + * @param array $actionTypes + */ + public function __construct( + private readonly array $scopeTypes, + private readonly array $actionTypes, + ) { } - public function getBlockPrefix(): string + /** @param array $options */ + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_catalog_promotion'; + $builder + ->add('scopes', LiveCollectionType::class, [ + 'entry_type' => CatalogPromotionScopeType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'button_add_type' => AddButtonType::class, + 'button_add_options' => [ + 'label' => 'sylius.ui.add_scope', + 'types' => $this->scopeTypes, + ], + 'button_delete_options' => [ + 'label' => false, + ], + ]) + ->add('actions', LiveCollectionType::class, [ + 'entry_type' => CatalogPromotionActionType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'button_add_type' => AddButtonType::class, + 'button_add_options' => [ + 'label' => 'sylius.ui.add_action', + 'types' => $this->actionTypes, + ], + 'button_delete_options' => [ + 'label' => false, + ], + ]) + ; } public function getParent(): string { return BaseCatalogPromotionType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_catalog_promotion'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelPriceHistoryConfigTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelPriceHistoryConfigType.php similarity index 87% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelPriceHistoryConfigTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/ChannelPriceHistoryConfigType.php index 5606ed34aca..3f29dce0f19 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ChannelPriceHistoryConfigTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelPriceHistoryConfigType.php @@ -11,24 +11,23 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension; +namespace Sylius\Bundle\AdminBundle\Form\Type; use Doctrine\Common\Collections\ArrayCollection; use Sylius\Bundle\AdminBundle\Form\DataTransformer\ResourceToIdentifierTransformer; -use Sylius\Bundle\AdminBundle\Form\Type\TaxonAutocompleteType; -use Sylius\Bundle\CoreBundle\Form\Type\ChannelPriceHistoryConfigType; +use Sylius\Bundle\CoreBundle\Form\Type\ChannelPriceHistoryConfigType as BaseChannelPriceHistoryConfigType; use Sylius\Bundle\ResourceBundle\Form\DataTransformer\RecursiveTransformer; use Sylius\Component\Core\Model\ChannelPriceHistoryConfigInterface; use Sylius\Component\Core\Model\TaxonInterface; use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface; -use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\DataMapperInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\ReversedTransformer; use Webmozart\Assert\Assert; -final class ChannelPriceHistoryConfigTypeExtension extends AbstractTypeExtension implements DataMapperInterface +final class ChannelPriceHistoryConfigType extends AbstractType implements DataMapperInterface { /** @param TaxonRepositoryInterface $taxonRepository */ public function __construct( @@ -63,9 +62,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->setDataMapper($this); } - public static function getExtendedTypes(): iterable + public function getParent(): string { - yield ChannelPriceHistoryConfigType::class; + return BaseChannelPriceHistoryConfigType::class; } public function mapDataToForms(mixed $viewData, \Traversable $forms): void @@ -94,4 +93,9 @@ public function mapFormsToData(\Traversable $forms, mixed &$viewData): void $this->dataMapper->mapFormsToData(new ArrayCollection($forms), $viewData); } + + public function getBlockPrefix(): string + { + return 'sylius_admin_channel_price_history_config'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelType.php index 1a297cf71a0..af5c4ca88e8 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ChannelType.php @@ -15,16 +15,31 @@ use Sylius\Bundle\ChannelBundle\Form\Type\ChannelType as BaseChannelType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; final class ChannelType extends AbstractType { - public function getBlockPrefix(): string + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_channel'; + $builder + ->add('menuTaxon', TaxonAutocompleteType::class, [ + 'label' => 'sylius.form.channel.menu_taxon', + 'multiple' => false, + ]) + ->add('channelPriceHistoryConfig', ChannelPriceHistoryConfigType::class, [ + 'label' => false, + 'required' => false, + ]) + ; } public function getParent(): string { return BaseChannelType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_channel'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/CountryType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/CountryType.php index 98fcc9f3cf3..fd173096f84 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/CountryType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/CountryType.php @@ -14,17 +14,88 @@ namespace Sylius\Bundle\AdminBundle\Form\Type; use Sylius\Bundle\AddressingBundle\Form\Type\CountryType as BaseCountryType; +use Sylius\Bundle\AddressingBundle\Form\Type\ProvinceType; +use Sylius\Component\Addressing\Model\CountryInterface; +use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\CountryType as SymfonyCountryType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; +use Symfony\Component\Intl\Countries; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class CountryType extends AbstractType { - public function getBlockPrefix(): string + /** @param RepositoryInterface $countryRepository */ + public function __construct(private readonly RepositoryInterface $countryRepository) { - return 'sylius_admin_country'; + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { + $options = [ + 'label' => 'sylius.form.country.name', + 'choice_loader' => null, + ]; + + $country = $event->getData(); + if ($country instanceof CountryInterface && null !== $country->getCode()) { + $options['disabled'] = true; + $options['choices'] = [$this->getCountryName($country->getCode()) => $country->getCode()]; + } else { + $options['choices'] = array_flip($this->getAvailableCountries()); + } + + $form = $event->getForm(); + $form->add('code', SymfonyCountryType::class, $options); + }); + + $builder + ->add('provinces', LiveCollectionType::class, [ + 'entry_type' => ProvinceType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'button_add_options' => [ + 'label' => 'sylius.form.country.add_province', + ], + ]) + ->add('enabled', CheckboxType::class, [ + 'label' => 'sylius.form.country.enabled', + ]) + ; } public function getParent(): string { return BaseCountryType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_country'; + } + + private function getCountryName(string $code): string + { + return Countries::getName($code); + } + + /** @return string[] */ + private function getAvailableCountries(): array + { + $availableCountries = Countries::getNames(); + + /** @var CountryInterface[] $definedCountries */ + $definedCountries = $this->countryRepository->findAll(); + + foreach ($definedCountries as $country) { + unset($availableCountries[$country->getCode()]); + } + + return $availableCountries; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/Grid/Filter/UxAutocompleteFilterType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/Grid/Filter/UxAutocompleteFilterType.php index 6b33fa815b1..de9a215abbc 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/Grid/Filter/UxAutocompleteFilterType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/Grid/Filter/UxAutocompleteFilterType.php @@ -44,4 +44,9 @@ public function getParent(): string { return BaseEntityAutocompleteType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_ux_entity_autocomplete'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/OrderType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/OrderType.php index 44051384dbf..54a6b9c7554 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/OrderType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/OrderType.php @@ -15,16 +15,37 @@ use Sylius\Bundle\OrderBundle\Form\Type\OrderType as BaseOrderType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; final class OrderType extends AbstractType { - public function getBlockPrefix(): string + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_order'; + $builder + ->add('shippingAddress', AddressType::class, [ + 'add_build_address_form_subscriber' => $options['add_build_address_form_subscriber'], + ]) + ->add('billingAddress', AddressType::class, [ + 'add_build_address_form_subscriber' => $options['add_build_address_form_subscriber'], + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + parent::configureOptions($resolver); + + $resolver->setDefaults(['add_build_address_form_subscriber' => true]); } public function getParent(): string { return BaseOrderType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_order'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductAssociationsType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductAssociationsType.php index 65ebf654bc9..7d28b1d4577 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductAssociationsType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductAssociationsType.php @@ -54,4 +54,9 @@ public function getParent(): string { return BaseProductAssociationsType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_product_associations'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductGenerateVariantsType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductGenerateVariantsType.php index e19081d2823..a82b293d90c 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductGenerateVariantsType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductGenerateVariantsType.php @@ -14,17 +14,35 @@ namespace Sylius\Bundle\AdminBundle\Form\Type; use Sylius\Bundle\ProductBundle\Form\Type\ProductGenerateVariantsType as BaseProductGenerateVariantsType; +use Sylius\Bundle\ProductBundle\Form\Type\ProductVariantGenerationType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class ProductGenerateVariantsType extends AbstractType { - public function getBlockPrefix(): string + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_product_generate_variants'; + $builder + ->add('variants', LiveCollectionType::class, [ + 'entry_type' => ProductVariantGenerationType::class, + 'allow_add' => false, + 'allow_delete' => true, + 'by_reference' => false, + 'label' => false, + 'button_delete_options' => [ + 'label' => false, + ], + ]); } public function getParent(): string { return BaseProductGenerateVariantsType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_product_generate_variants'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductImageTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductImageType.php similarity index 79% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/ProductImageTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/ProductImageType.php index 8124b3bfdf3..38890a3017d 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ProductImageTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductImageType.php @@ -11,17 +11,17 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension; +namespace Sylius\Bundle\AdminBundle\Form\Type; use Doctrine\ORM\QueryBuilder; -use Sylius\Bundle\CoreBundle\Form\Type\Product\ProductImageType; +use Sylius\Bundle\CoreBundle\Form\Type\Product\ProductImageType as BaseProductImageType; use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; use Sylius\Component\Core\Model\ProductInterface; use Symfony\Bridge\Doctrine\Form\Type\EntityType; -use Symfony\Component\Form\AbstractTypeExtension; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -final class ProductImageTypeExtension extends AbstractTypeExtension +final class ProductImageType extends AbstractType { public function __construct(private readonly string $productVariantClass) { @@ -50,8 +50,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void } } - public static function getExtendedTypes(): iterable + public function getParent(): string { - return [ProductImageType::class]; + return BaseProductImageType::class; + } + + public function getBlockPrefix(): string + { + return 'sylius_admin_product_image'; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductType.php index c202774bfc3..a7be3f87db3 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ProductType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ProductType.php @@ -15,16 +15,37 @@ use Sylius\Bundle\ProductBundle\Form\Type\ProductType as BaseProductType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class ProductType extends AbstractType { - public function getBlockPrefix(): string + /** @param array $options */ + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_product'; + $builder + ->add('images', LiveCollectionType::class, [ + 'entry_type' => ProductImageType::class, + 'entry_options' => ['product' => $options['data']], + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'label' => 'sylius.form.product.images', + 'block_name' => 'entry', + ]) + ->add('associations', ProductAssociationsType::class, [ + 'label' => false, + ]) + ; } public function getParent(): string { return BaseProductType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_product'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodRuleTypeExtension.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodRuleType.php similarity index 72% rename from src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodRuleTypeExtension.php rename to src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodRuleType.php index 0ab190a09ca..e100cd18c16 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Extension/ShippingMethodRuleTypeExtension.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodRuleType.php @@ -11,17 +11,17 @@ declare(strict_types=1); -namespace Sylius\Bundle\AdminBundle\Form\Extension; +namespace Sylius\Bundle\AdminBundle\Form\Type; -use Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodRuleType; -use Symfony\Component\Form\AbstractTypeExtension; +use Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodRuleType as BaseShippingMethodRuleType; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -final class ShippingMethodRuleTypeExtension extends AbstractTypeExtension +final class ShippingMethodRuleType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { @@ -38,8 +38,13 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setDefault('types', []); } - public static function getExtendedTypes(): iterable + public function getParent(): string { - yield ShippingMethodRuleType::class; + return BaseShippingMethodRuleType::class; + } + + public function getBlockPrefix(): string + { + return 'sylius_admin_shipping_method_rule'; } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodType.php index 21be8de278f..e5ce991c602 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ShippingMethodType.php @@ -15,16 +15,47 @@ use Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodType as BaseShippingMethodType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class ShippingMethodType extends AbstractType { - public function getBlockPrefix(): string + /** @param array $types */ + public function __construct(private readonly array $types) { - return 'sylius_admin_shipping_method'; + } + + /** @param array $options */ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('rules', LiveCollectionType::class, [ + 'entry_type' => ShippingMethodRuleType::class, + 'entry_options' => [ + 'types' => $this->types, + ], + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'button_add_type' => AddButtonType::class, + 'button_add_options' => [ + 'label' => 'sylius.ui.add_rule', + 'types' => $this->types, + ], + 'button_delete_options' => [ + 'label' => false, + ], + ]) + ; } public function getParent(): string { return BaseShippingMethodType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_shipping_method'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/ZoneType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/ZoneType.php index 9343cd46a88..748caa27ba2 100644 --- a/src/Sylius/Bundle/AdminBundle/Form/Type/ZoneType.php +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/ZoneType.php @@ -13,18 +13,42 @@ namespace Sylius\Bundle\AdminBundle\Form\Type; +use Sylius\Bundle\AddressingBundle\Form\Type\ZoneMemberType; use Sylius\Bundle\AddressingBundle\Form\Type\ZoneType as BaseZoneType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; +use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType; final class ZoneType extends AbstractType { - public function getBlockPrefix(): string + public function buildForm(FormBuilderInterface $builder, array $options): void { - return 'sylius_admin_zone'; + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { + $entryOptions = $event->getForm()->get('members')->getConfig()->getOptions()['entry_options']; + + $event->getForm()->add('members', LiveCollectionType::class, [ + 'entry_type' => ZoneMemberType::class, + 'entry_options' => $entryOptions, + 'button_add_options' => [ + 'label' => 'sylius.form.zone.add_member', + ], + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'delete_empty' => true, + ]); + }); } public function getParent(): string { return BaseZoneType::class; } + + public function getBlockPrefix(): string + { + return 'sylius_admin_zone'; + } } diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/admin_user.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/admin_user.yml index 1f01c1a1dd9..62ba4743c7e 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/admin_user.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/admin_user.yml @@ -7,6 +7,8 @@ sylius_admin_admin_user: except: ['show'] redirect: index grid: sylius_admin_admin_user + form: + type: Sylius\Bundle\AdminBundle\Form\Type\AdminUserType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/catalog_promotion.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/catalog_promotion.yaml index 4ac161fe2d0..1788deeb61e 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/catalog_promotion.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/catalog_promotion.yaml @@ -6,6 +6,8 @@ sylius_admin_catalog_promotion: except: ['delete'] redirect: update grid: sylius_admin_catalog_promotion + form: + type: Sylius\Bundle\AdminBundle\Form\Type\CatalogPromotionType permission: true type: sylius.resource diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/channel.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/channel.yml index 0334c0fd6f3..e1ef1c96c41 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/channel.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/channel.yml @@ -6,6 +6,8 @@ sylius_admin_channel: except: ['show'] redirect: update grid: sylius_admin_channel + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ChannelType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/country.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/country.yml index 7ba74049877..f0b388a53b1 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/country.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/country.yml @@ -6,6 +6,8 @@ sylius_admin_country: except: ['show', 'delete'] redirect: update grid: sylius_admin_country + form: + type: Sylius\Bundle\AdminBundle\Form\Type\CountryType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/currency.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/currency.yml index c131b0532dc..52194da3252 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/currency.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/currency.yml @@ -6,6 +6,8 @@ sylius_admin_currency: only: ['index', 'create'] redirect: index grid: sylius_admin_currency + form: + type: Sylius\Bundle\AdminBundle\Form\Type\CurrencyType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer.yml index 3988a2287b5..8568945e296 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer.yml @@ -6,6 +6,8 @@ sylius_admin_customer: except: ['delete'] redirect: update grid: sylius_admin_customer + form: + type: Sylius\Bundle\AdminBundle\Form\Type\CustomerType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer_group.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer_group.yml index d250916b082..e4336c2d634 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer_group.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/customer_group.yml @@ -6,6 +6,8 @@ sylius_admin_customer_group: except: ['show'] redirect: update grid: sylius_admin_customer_group + form: + type: Sylius\Bundle\AdminBundle\Form\Type\CustomerGroupType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/exchange_rate.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/exchange_rate.yml index d5304f8db47..3fad1c7cf38 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/exchange_rate.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/exchange_rate.yml @@ -6,6 +6,8 @@ sylius_admin_exchange_rate: except: ['show'] redirect: update grid: sylius_admin_exchange_rate + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ExchangeRateType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/locale.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/locale.yml index 5cb5e2e0e46..6dd52c0f817 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/locale.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/locale.yml @@ -6,6 +6,8 @@ sylius_admin_locale: except: ['show', 'delete'] redirect: index grid: sylius_admin_locale + form: + type: Sylius\Bundle\AdminBundle\Form\Type\LocaleType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/order.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/order.yml index 156d22255c6..44a0b6daef4 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/order.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/order.yml @@ -5,6 +5,8 @@ sylius_admin_order: templates: "@SyliusAdmin\\shared\\crud" only: ['index'] grid: sylius_admin_order + form: + type: Sylius\Bundle\AdminBundle\Form\Type\OrderType permission: true vars: all: @@ -55,6 +57,7 @@ sylius_admin_order_update: permission: true template: "@SyliusAdmin/shared/crud/update.html.twig" form: + type: Sylius\Bundle\AdminBundle\Form\Type\OrderType options: validation_groups: - sylius_shipping_address_update @@ -129,7 +132,7 @@ sylius_admin_order_shipment_ship: redirect: referer section: admin permission: true - form: Sylius\Bundle\ShippingBundle\Form\Type\ShipmentShipType + form: Sylius\Bundle\AdminBundle\Form\Type\ShipmentShipType vars: route: parameters: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/payment_method.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/payment_method.yml index 0c16926b5fa..0507490a1ad 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/payment_method.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/payment_method.yml @@ -6,6 +6,8 @@ sylius_admin_payment_method: except: ['show'] redirect: update grid: sylius_admin_payment_method + form: + type: Sylius\Bundle\AdminBundle\Form\Type\PaymentMethodType permission: true vars: all: @@ -27,6 +29,8 @@ sylius_admin_payment_method_create: method: createWithGateway arguments: gatewayFactory: $factory + form: + type: Sylius\Bundle\AdminBundle\Form\Type\PaymentMethodType template: "@SyliusAdmin/shared/crud/create.html.twig" redirect: sylius_admin_payment_method_update permission: true diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product.yml index edf443278d9..ff176b454a6 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product.yml @@ -5,6 +5,8 @@ sylius_admin_product: templates: "@SyliusAdmin\\shared\\crud" redirect: update grid: sylius_admin_product + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductType permission: true vars: all: @@ -39,6 +41,8 @@ sylius_admin_product_create_simple: permission: true factory: method: createWithVariant + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductType template: "@SyliusAdmin/shared/crud/create.html.twig" redirect: sylius_admin_product_update vars: @@ -58,7 +62,7 @@ sylius_admin_product_variant_generate: route: sylius_admin_product_variant_index parameters: { productId: $productId } form: - type: Sylius\Bundle\ProductBundle\Form\Type\ProductGenerateVariantsType + type: Sylius\Bundle\AdminBundle\Form\Type\ProductGenerateVariantsType repository: method: find arguments: [$productId] diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_association_type.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_association_type.yml index 371acc932c8..830b6319c70 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_association_type.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_association_type.yml @@ -7,6 +7,8 @@ sylius_admin_product_association_type: except: ['show'] redirect: update grid: sylius_admin_product_association_type + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductAssociationTypeType vars: all: subheader: sylius.ui.manage_association_types_of_your_products diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_attribute.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_attribute.yml index b231ddd6bbd..173baa0a39b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_attribute.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_attribute.yml @@ -6,6 +6,8 @@ sylius_admin_product_attribute: except: ['show', 'create'] redirect: update grid: sylius_admin_product_attribute + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductAttributeType permission: true vars: all: @@ -27,6 +29,8 @@ sylius_admin_product_attribute_create: method: createTyped arguments: type: $type + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductAttributeType template: "@SyliusAdmin/shared/crud/create.html.twig" redirect: sylius_admin_product_attribute_update permission: true diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_option.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_option.yml index 8a3d3eec06e..238b3635257 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_option.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_option.yml @@ -6,6 +6,8 @@ sylius_admin_product_option: except: ['show'] redirect: update grid: sylius_admin_product_option + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductOptionType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_review.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_review.yml index be212475ff1..43e588f7564 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_review.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_review.yml @@ -7,6 +7,8 @@ sylius_admin_product_review: except: ['show', 'create'] redirect: update grid: sylius_admin_product_review + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductReviewType vars: all: subheader: sylius.ui.manage_reviews_of_your_products diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_variant.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_variant.yml index 1ad864511c0..e687d754a07 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_variant.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/product_variant.yml @@ -27,6 +27,8 @@ sylius_admin_product_variant_create: - expr:notFoundOnNull(service('sylius.repository.product').find($productId)) template: "@SyliusAdmin/shared/crud/create.html.twig" grid: sylius_admin_product_variant + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductVariantType section: admin redirect: route: sylius_admin_product_variant_index @@ -45,6 +47,8 @@ sylius_admin_product_variant_update: _sylius: template: "@SyliusAdmin/shared/crud/update.html.twig" grid: sylius_admin_product_variant + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ProductVariantType section: admin redirect: route: sylius_admin_product_variant_index diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion.yml index 0c0a9fe09b1..415ab691f71 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion.yml @@ -6,6 +6,8 @@ sylius_admin_promotion: except: ['show'] redirect: update grid: sylius_admin_promotion + form: + type: Sylius\Bundle\AdminBundle\Form\Type\PromotionType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion_coupon.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion_coupon.yml index c160da8f607..2bd43729fbc 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion_coupon.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/promotion_coupon.yml @@ -29,6 +29,8 @@ sylius_admin_promotion_coupon_create: - expr:notFoundOnNull(service('sylius.repository.promotion').find($promotionId)) template: "@SyliusAdmin/crud/create.html.twig" grid: sylius_admin_promotion_coupon + form: + type: Sylius\Bundle\AdminBundle\Form\Type\PromotionCouponType section: admin redirect: route: sylius_admin_promotion_coupon_index @@ -51,6 +53,8 @@ sylius_admin_promotion_coupon_update: _sylius: template: "@SyliusAdmin/crud/update.html.twig" grid: sylius_admin_promotion_coupon + form: + type: Sylius\Bundle\AdminBundle\Form\Type\PromotionCouponType section: admin redirect: route: sylius_admin_promotion_coupon_index diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipment.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipment.yml index 1bdc3a7c146..c223454cbf2 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipment.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipment.yml @@ -27,7 +27,7 @@ sylius_admin_shipment_ship: transition: ship redirect: referer flash: sylius.shipment.shipped - form: Sylius\Bundle\ShippingBundle\Form\Type\ShipmentShipType + form: Sylius\Bundle\AdminBundle\Form\Type\ShipmentShipType sylius_admin_shipment_resend_confirmation_email: path: /shipments/{id}/resend-confirmation-email diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_category.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_category.yml index c4b59fda92d..4eac0f69731 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_category.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_category.yml @@ -6,6 +6,8 @@ sylius_admin_shipping_category: except: ['show'] redirect: update grid: sylius_admin_shipping_category + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ShippingCategoryType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_method.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_method.yml index 3ec02671dbc..23e481743a6 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_method.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/shipping_method.yml @@ -6,6 +6,8 @@ sylius_admin_shipping_method: except: ['show'] redirect: update grid: sylius_admin_shipping_method + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ShippingMethodType permission: true type: sylius.resource diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_category.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_category.yml index 2d5e035b0df..79a6bb9cda9 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_category.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_category.yml @@ -6,6 +6,8 @@ sylius_admin_tax_category: except: ['show'] redirect: update grid: sylius_admin_tax_category + form: + type: Sylius\Bundle\AdminBundle\Form\Type\TaxCategoryType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_rate.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_rate.yml index cc8ca418aa6..3bb6500985b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_rate.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/tax_rate.yml @@ -6,6 +6,8 @@ sylius_admin_tax_rate: except: ['show'] redirect: update grid: sylius_admin_tax_rate + form: + type: Sylius\Bundle\AdminBundle\Form\Type\TaxRateType permission: true vars: all: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/zone.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/zone.yml index 94cd8fc30ec..8b64aed15c5 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/zone.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/zone.yml @@ -6,6 +6,8 @@ sylius_admin_zone: except: ['show', 'create'] redirect: update grid: sylius_admin_zone + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ZoneType permission: true vars: all: @@ -25,6 +27,8 @@ sylius_admin_zone_create: method: createTyped arguments: type: $type + form: + type: Sylius\Bundle\AdminBundle\Form\Type\ZoneType template: "@SyliusAdmin/shared/crud/create.html.twig" redirect: sylius_admin_zone_update permission: true diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/form.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/form.xml index 3fffe53fda9..4cd7187703f 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services/form.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/form.xml @@ -25,52 +25,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - %sylius.shipping_method_rules% - - - - - - - - - %sylius.model.product_variant.class% - + + %sylius.form.type.admin.password_reset_request.validation_groups% + - - + + %sylius.form.type.admin.reset_password.validation_groups% + - - - - - - + + + @@ -79,10 +46,6 @@ - - - - @@ -92,11 +55,15 @@ - + + + + + @@ -112,104 +79,62 @@ - - - - - - - %sylius.model.product.class% - - - - - - %sylius.model.product_variant.class% - - - - - - %sylius.model.taxon.class% + - - - %sylius.model.product_attribute.class% + + - - - %sylius.form.type.admin.password_reset_request.validation_groups% + + %sylius.catalog_promotion.scopes_types% + %sylius.catalog_promotion.actions_types% - - %sylius.form.type.admin.reset_password.validation_groups% + - + + - - - %sylius.catalog_promotion.scopes_types% - %sylius.catalog_promotion.actions_types% - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - + + + - - - + + + - + - + + + + + + @@ -253,10 +178,27 @@ + + %sylius.model.product_attribute.class% + + + + + + %sylius.model.product.class% + + + + + + %sylius.model.product_variant.class% + + + @@ -269,6 +211,12 @@ + + %sylius.model.product_variant.class% + + + + @@ -282,6 +230,11 @@ + %sylius.shipping_method_rules% + + + + @@ -297,8 +250,23 @@ + + %sylius.model.taxon.class% + + + + + + + + + + + + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/product/form.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/product/form.xml index 8e55d558d8e..60b0238cc94 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services/product/form.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/product/form.xml @@ -13,8 +13,8 @@ - - + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml index 0b1c5c2cbfa..e1a492f5b49 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml @@ -16,7 +16,7 @@ class="Sylius\Bundle\AdminBundle\Twig\Component\CatalogPromotion\FormComponent" > - Sylius\Bundle\PromotionBundle\Form\Type\CatalogPromotionType + Sylius\Bundle\AdminBundle\Form\Type\CatalogPromotionType - Sylius\Bundle\ChannelBundle\Form\Type\ChannelType + Sylius\Bundle\AdminBundle\Form\Type\ChannelType - Sylius\Bundle\AddressingBundle\Form\Type\CountryType + Sylius\Bundle\AdminBundle\Form\Type\CountryType - Sylius\Bundle\OrderBundle\Form\Type\OrderType + Sylius\Bundle\AdminBundle\Form\Type\OrderType @@ -135,7 +135,7 @@ class="Sylius\Bundle\AdminBundle\Twig\Component\PaymentMethod\FormComponent" > - Sylius\Bundle\PaymentBundle\Form\Type\PaymentMethodType + Sylius\Bundle\AdminBundle\Form\Type\PaymentMethodType - Sylius\Bundle\ProductBundle\Form\Type\ProductType + Sylius\Bundle\AdminBundle\Form\Type\ProductType @@ -166,7 +166,7 @@ class="Sylius\Bundle\AdminBundle\Twig\Component\Product\GenerateProductVariantsFormComponent" > - Sylius\Bundle\ProductBundle\Form\Type\ProductGenerateVariantsType + Sylius\Bundle\AdminBundle\Form\Type\ProductGenerateVariantsType - Sylius\Bundle\PromotionBundle\Form\Type\PromotionType + Sylius\Bundle\AdminBundle\Form\Type\PromotionType - Sylius\Bundle\AddressingBundle\Form\Type\ZoneType + Sylius\Bundle\AdminBundle\Form\Type\ZoneType - Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodType + Sylius\Bundle\AdminBundle\Form\Type\ShippingMethodType - Sylius\Bundle\ShippingBundle\Form\Type\ShipmentShipType + Sylius\Bundle\AdminBundle\Form\Type\ShipmentShipType - diff --git a/src/Sylius/Bundle/AdminBundle/Twig/Component/Order/FormComponent.php b/src/Sylius/Bundle/AdminBundle/Twig/Component/Order/FormComponent.php index 47100810334..3376155b313 100644 --- a/src/Sylius/Bundle/AdminBundle/Twig/Component/Order/FormComponent.php +++ b/src/Sylius/Bundle/AdminBundle/Twig/Component/Order/FormComponent.php @@ -29,7 +29,7 @@ class FormComponent use DefaultActionTrait; use HookableLiveComponentTrait; - #[LiveProp] + #[LiveProp(fieldName: 'resource')] public ?Order $order = null; /** @param class-string $formClass */ diff --git a/src/Sylius/Bundle/CoreBundle/Form/Extension/OrderTypeExtension.php b/src/Sylius/Bundle/CoreBundle/Form/Extension/OrderTypeExtension.php index daac6a4c282..acb7f5777b3 100644 --- a/src/Sylius/Bundle/CoreBundle/Form/Extension/OrderTypeExtension.php +++ b/src/Sylius/Bundle/CoreBundle/Form/Extension/OrderTypeExtension.php @@ -17,29 +17,17 @@ use Sylius\Bundle\OrderBundle\Form\Type\OrderType; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; final class OrderTypeExtension extends AbstractTypeExtension { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('shippingAddress', AddressType::class, [ - 'add_build_address_form_subscriber' => $options['add_build_address_form_subscriber'], - ]) - ->add('billingAddress', AddressType::class, [ - 'add_build_address_form_subscriber' => $options['add_build_address_form_subscriber'], - ]) + ->add('shippingAddress', AddressType::class) + ->add('billingAddress', AddressType::class) ; } - public function configureOptions(OptionsResolver $resolver): void - { - parent::configureOptions($resolver); - - $resolver->setDefaults(['add_build_address_form_subscriber' => true]); - } - public static function getExtendedTypes(): iterable { return [OrderType::class];