Skip to content

Commit

Permalink
Merge branch '1.1' into 1.2
Browse files Browse the repository at this point in the history
* 1.1:
  Apply coding standard fixes
  Update "Configuring taxation" docs
  [GridBundle] Do not put unnecessary "andWhere" in ExpressionBuilder
  [Grid] Fix getting enabled grid items
  [ThemeBundle] Replace "symfony/symfony" dependency with specific Symfony packages
  Keep the existing pagination when changing sorting on product list page
  Fix API validation tests
  [ShippingBundle] Add validation for ShippingMethod calculator
  Narrow down selectors to prevent unexpected bugs
  [CoreBundle] Make sure promotion action/rule amount is an integer
  set gender `u` as default value - resolves #8493
  [Order] Fixed sylius:remove-expired-carts help
  Make ArrayGridProvider more performant & suitable for PHP-PM
  [Documentation] Fix API example for creating a taxon
  • Loading branch information
pamil committed Oct 3, 2018
2 parents 2ad8e90 + 84365ff commit 9c76edf
Show file tree
Hide file tree
Showing 23 changed files with 196 additions and 216 deletions.
16 changes: 11 additions & 5 deletions docs/api/taxons.rst
Expand Up @@ -77,6 +77,10 @@ Definition
+------------------------------------+----------------+--------------------------------------+
| code | request | **(unique)** Taxon identifier |
+------------------------------------+----------------+--------------------------------------+
| translations['localeCode']['name'] | request | Taxon name |
+------------------------------------+----------------+--------------------------------------+
| translations['localeCode']['slug'] | request | **(unique)** Taxon slug |
+------------------------------------+----------------+--------------------------------------+

Example
^^^^^^^
Expand All @@ -91,7 +95,13 @@ To create new taxon use the below method:
-X POST \
--data '
{
"code": "toys"
"code": "toys",
"translations": {
"en_US": {
"name": "Toys",
"slug": "category/toys"
}
}
}
'
Expand Down Expand Up @@ -170,10 +180,6 @@ You can also create a taxon with additional (not required) fields:
+-------------------------------------------+----------------+------------------------------------+
| Parameter | Parameter type | Description |
+===========================================+================+====================================+
| translations['localeCode']['name'] | request | Name of the taxon |
+-------------------------------------------+----------------+------------------------------------+
| translations['localeCode']['slug'] | request | **(unique)** Slug |
+-------------------------------------------+----------------+------------------------------------+
| translations['localeCode']['description'] | request | Description of the taxon |
+-------------------------------------------+----------------+------------------------------------+
| parent | request | The parent taxon's code |
Expand Down
Expand Up @@ -14,24 +14,21 @@ First step is to create a new tax category.
public function configureAction()
{
$factory = $this->container->get('sylius.factory.tax_category');
$manager = $this->container->get('sylius.manager.tax_category');
$clothing = $factory
->createNew()
->setName('Clothing')
->setDescription('T-Shirts and this kind of stuff.')
;
$food = $factory
->createNew()
->setName('Food')
->setDescription('Yummy!')
;
$manager->persist($clothing);
$manager->persist($food);
$manager->flush();
$taxCategoryFactory = $this->container->get('sylius.factory.tax_category');
$taxCategoryManager = $this->container->get('sylius.manager.tax_category');
$clothingTaxCategory = $taxCategoryFactory->createNew();
$clothingTaxCategory->setName('Clothing');
$clothingTaxCategory->setDescription('T-Shirts and this kind of stuff.');
$foodTaxCategory = $taxCategoryFactory->createNew();
$foodTaxCategory->setName('Food');
$foodTaxCategory->setDescription('Yummy!');
$taxCategoryManager->persist($clothingTaxCategory);
$taxCategoryManager->persist($foodTaxCategory);
$taxCategoryManager->flush();
}
Categorizing the taxables
Expand All @@ -45,16 +42,16 @@ Second thing to do is to classify the taxables, in our example we'll get two pro
public function configureAction()
{
$tshirt = // ...
$banana = // ... Some logic behind loading entities.
$tshirtProduct = // ...
$bananaProduct = // ... Some logic behind loading entities.
$repository = $this->container->get('sylius.repository.tax_category');
$taxCategoryRepository = $this->container->get('sylius.repository.tax_category');
$clothing = $repository->findOneBy(array('name' => 'Clothing'));
$food = $repository->findOneBy(array('name' => 'Food'));
$clothingTaxCategory = $taxCategoryRepository->findOneBy(['name' => 'Clothing']);
$foodTaxCategory = $taxCategoryRepository->findOneBy(['name' => 'Food']);
$tshirt->setTaxCategory($clothing);
$banana->setTaxCategory($food);
$tshirtProduct->setTaxCategory($clothingTaxCategory);
$bananaProduct->setTaxCategory($foodTaxCategory);
// Save the product entities.
}
Expand All @@ -72,27 +69,26 @@ Finally, you have to create appropriate tax rates for each of categories.
{
$taxCategoryRepository = $this->container->get('sylius.repository.tax_category');
$clothing = $taxCategoryRepository->findOneBy(array('name' => 'Clothing'));
$food = $taxCategoryRepository->findOneBy(array('name' => 'Food'));
$clothingTaxCategory = $taxCategoryRepository->findOneBy(['name' => 'Clothing']);
$foodTaxCategory = $taxCategoryRepository->findOneBy(['name' => 'Food']);
$taxRateFactory = $this->container->get('sylius.factory.tax_rate');
$taxRateManager = $this->container->get('sylius.repository.tax_rate');
$factory = $this->container->get('sylius.factory.tax_rate');
$manager = $this->container->get('sylius.repository.tax_rate');
$clothingTaxRate = $taxRateFactory->createNew();
$clothingTaxRate->setCategory($clothingTaxCategory);
$clothingTaxRate->setName('Clothing Tax');
$clothingTaxRate->setAmount(0.08);
$clothingTax = $factory
->createNew()
->setName('Clothing Tax')
->setAmount(0.08)
;
$foodTax = $factory
->createNew()
->setName('Food')
->setAmount(0.12)
;
$foodTaxRate = $taxRateFactory->createNew();
$foodTaxRate->setCategory($foodTaxCategory);
$foodTaxRate->setName('Food');
$foodTaxRate->setAmount(0.12);
$manager->persist($clothingTax);
$manager->persist($foodTax);
$taxRateManager->persist($clothingTaxRate);
$taxRateManager->persist($foodTaxRate);
$manager->flush();
$taxRateManager->flush();
}
Expand Down
Expand Up @@ -78,7 +78,7 @@ protected function configureOptions(OptionsResolver $resolver): void
->setNormalizer('configuration', function (Options $options, $configuration): array {
foreach ($configuration as $channelCode => $channelConfiguration) {
if (isset($channelConfiguration['amount'])) {
$configuration[$channelCode]['amount'] *= 100;
$configuration[$channelCode]['amount'] = (int) ($configuration[$channelCode]['amount'] * 100);
}

if (isset($channelConfiguration['percentage'])) {
Expand Down
Expand Up @@ -78,7 +78,7 @@ protected function configureOptions(OptionsResolver $resolver): void
->setNormalizer('configuration', function (Options $options, $configuration): array {
foreach ($configuration as $channelCode => $channelConfiguration) {
if (isset($channelConfiguration['amount'])) {
$configuration[$channelCode]['amount'] *= 100;
$configuration[$channelCode]['amount'] = (int) ($configuration[$channelCode]['amount'] * 100);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Bundle/CustomerBundle/Form/Type/GenderType.php
Expand Up @@ -31,6 +31,7 @@ public function configureOptions(OptionsResolver $resolver): void
'sylius.gender.male' => CustomerInterface::MALE_GENDER,
'sylius.gender.female' => CustomerInterface::FEMALE_GENDER,
],
'empty_data' => CustomerInterface::UNKNOWN_GENDER,
]);
}

Expand Down
Expand Up @@ -86,7 +86,7 @@ public function lessThan(string $field, $value)
$parameterName = $this->getParameterName($field);
$this->queryBuilder->setParameter($parameterName, $value);

$this->queryBuilder->andWhere($this->getFieldName($field) . ' < :' . $parameterName);
return $this->queryBuilder->expr()->lt($this->getFieldName($field), ':' . $parameterName);
}

/**
Expand All @@ -97,7 +97,7 @@ public function lessThanOrEqual(string $field, $value)
$parameterName = $this->getParameterName($field);
$this->queryBuilder->setParameter($parameterName, $value);

$this->queryBuilder->andWhere($this->getFieldName($field) . ' <= :' . $parameterName);
return $this->queryBuilder->expr()->lte($this->getFieldName($field), ':' . $parameterName);
}

/**
Expand All @@ -108,7 +108,7 @@ public function greaterThan(string $field, $value)
$parameterName = $this->getParameterName($field);
$this->queryBuilder->setParameter($parameterName, $value);

$this->queryBuilder->andWhere($this->getFieldName($field) . ' > :' . $parameterName);
return $this->queryBuilder->expr()->gt($this->getFieldName($field), ':' . $parameterName);
}

/**
Expand All @@ -119,7 +119,7 @@ public function greaterThanOrEqual(string $field, $value)
$parameterName = $this->getParameterName($field);
$this->queryBuilder->setParameter($parameterName, $value);

$this->queryBuilder->andWhere($this->getFieldName($field) . ' >= :' . $parameterName);
return $this->queryBuilder->expr()->gte($this->getFieldName($field), ':' . $parameterName);
}

/**
Expand Down
Expand Up @@ -26,7 +26,8 @@ protected function configure(): void
{
$this
->setName('sylius:remove-expired-carts')
->setDescription('Removes carts that have been idle for a configured period. Configuration parameter - sylius_order.cart_expires_after.');
->setDescription('Removes carts that have been idle for a period set in `sylius_order.expiration.cart` configuration key.')
;
}

/**
Expand Down
Expand Up @@ -29,6 +29,12 @@
<option name="groups">sylius</option>
</constraint>
</property>
<property name="calculator">
<constraint name="NotBlank">
<option name="message">sylius.shipping_method.calculator.not_blank</option>
<option name="groups">sylius</option>
</constraint>
</property>
<property name="translations">
<constraint name="Valid" />
</property>
Expand Down
Expand Up @@ -14,9 +14,7 @@ sylius:

shipping_method:
calculator:
max_length: sylius.shipping_method.calculator.max_length # FIXME
min_length: sylius.shipping_method.calculator.min_length # FIXME
not_blank: sylius.shipping_method.calculator.not_blank # FIXME
not_blank: 'Please select shipping method calculator.'
name:
max_length: 'Shipping method name must not be longer than {{ limit }} characters.'
min_length: 'Shipping method name must be at least {{ limit }} characters long.'
Expand Down
Expand Up @@ -3,7 +3,7 @@
{% set definition = resources.definition %}

{% set route = app.request.attributes.get('_route') %}
{% set route_parameters = app.request.attributes.get('_route_params') %}
{% set route_parameters = app.request.attributes.get('_route_params')|merge(app.request.query.all) %}

{% set criteria = app.request.query.get('criteria', {}) %}

Expand Down
3 changes: 2 additions & 1 deletion src/Sylius/Bundle/ShopBundle/composer.json
Expand Up @@ -31,7 +31,8 @@
"sonata-project/intl-bundle": "^2.2",
"sylius/core-bundle": "^1.2",
"sylius/ui-bundle": "^1.2",
"symfony/framework-bundle": "^3.4|^4.1.1"
"symfony/framework-bundle": "^3.4|^4.1.1",
"symfony/security-bundle": "^3.4|^4.1.1"
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^3.0",
Expand Down
23 changes: 18 additions & 5 deletions src/Sylius/Bundle/ThemeBundle/composer.json
Expand Up @@ -23,7 +23,19 @@
"php": "^7.1",

"doctrine/common": "^2.5",
"symfony/symfony": "^3.4|^4.1.1",
"symfony/asset": "^3.4|^4.1.1",
"symfony/config": "^3.4|^4.1.1",
"symfony/console": "^3.4|^4.1.1",
"symfony/dependency-injection": "^3.4|^4.1.1",
"symfony/filesystem": "^3.4|^4.1.1",
"symfony/finder": "^3.4|^4.1.1",
"symfony/form": "^3.4|^4.1.1",
"symfony/framework-bundle": "^3.4|^4.1.1",
"symfony/http-foundation": "^3.4|^4.1.1",
"symfony/http-kernel": "^3.4|^4.1.1",
"symfony/options-resolver": "^3.4|^4.1.1",
"symfony/templating": "^3.4|^4.1.1",
"symfony/translation": "^3.4|^4.1.1",
"zendframework/zend-hydrator": "^2.2"
},
"require-dev": {
Expand All @@ -32,10 +44,11 @@
"mikey179/vfsStream": "^1.6",
"phpspec/phpspec": "^4.0",
"phpunit/phpunit": "^6.5",
"sylius/registry": "^1.2",
"twig/twig": "^2.0",
"symfony/dependency-injection": "^3.4|^4.1.1",
"symfony/twig-bundle": "^3.4|^4.1.1"
"sylius/registry": "^1.1",
"symfony/browser-kit": "^3.4|^4.1.1",
"symfony/security-csrf": "^3.4|^4.1.1",
"symfony/twig-bundle": "^3.4|^4.1.1",
"twig/twig": "^2.0"
},
"conflict": {
"twig/twig": "^1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/UiBundle/Resources/private/js/app.js
Expand Up @@ -23,11 +23,11 @@
$('.link.ui.dropdown').dropdown({action: 'hide'});
$('.button.ui.dropdown').dropdown({action: 'hide'});
$('.ui.fluid.search.selection.ui.dropdown').dropdown();
$('.menu .item').tab();
$('.card .image').dimmer({on: 'hover'});
$('.ui.tabular.menu .item, .sylius-tabular-form .menu .item').tab();
$('.ui.card .dimmable.image, .ui.cards .card .dimmable.image').dimmer({on: 'hover'});
$('.ui.rating').rating('disable');

$('form.loadable button').on('click', function() {
$('form.loadable button[type=submit]').on('click', function() {
return $(this).closest('form').addClass('loading');
});
$('.loadable.button').on('click', function() {
Expand Down

0 comments on commit 9c76edf

Please sign in to comment.