[Taxonomy] Remove Taxonomy entity in favor of Taxon

This commit is contained in:
aramalipoor 2016-01-26 13:29:32 +03:30
parent c42d7873d5
commit 43845cc676
143 changed files with 699 additions and 3352 deletions

View file

@ -60,7 +60,7 @@ before_script:
- app/console assetic:dump --env=test_cached --no-debug
# Debug informations, PHP version & PHP configuration
# Its needed to remove the line with secret ariable, as it is listed in _SERVER variables
# Its needed to remove the line with secret variable, as it is listed in _SERVER variables
- php -v
- php -i | grep -v 'GITHUB_OAUTH_TOKEN\|SYMFONY__'

View file

@ -8,4 +8,4 @@ call bin\behat --strict -f progress -s inventory
call bin\behat --strict -f progress -s localization
call bin\behat --strict -f progress -s oauth
call bin\behat --strict -f progress -s reports
call bin\behat --strict -f progress -s taxonomies
call bin\behat --strict -f progress -s taxonomy

View file

@ -2,7 +2,7 @@ call bin\behat --strict -f progress -s products features/backend/products.featur
call bin\behat --strict -f progress -s products features/backend/product_attributes.feature
call bin\behat --strict -f progress -s products features/backend/product_options.feature
call bin\behat --strict -f progress -s products features/backend/product_archetypes.feature
call bin\behat --strict -f progress -s products features/backend/product_taxonomies.feature
call bin\behat --strict -f progress -s products features/backend/product_taxons.feature
call bin\behat --strict -f progress -s products features/backend/product_variants.feature
call bin\behat --strict -f progress -s products features/backend/products_filter.feature
call bin\behat --strict -f progress -s products features/frontend/products.feature

View file

@ -28,7 +28,7 @@ imports:
- suites/legacy/settings.yml
- suites/legacy/shipping.yml
- suites/legacy/taxation.yml
- suites/legacy/taxonomies.yml
- suites/legacy/taxonomy.yml
- suites/legacy/users.yml
- suites/ui_cart.yml

View file

@ -3,7 +3,7 @@
default:
suites:
taxonomies:
taxonomy:
contexts:
- Behat\MinkExtension\Context\MinkContext
- Sylius\Bundle\CoreBundle\Behat\HookContext
@ -14,4 +14,4 @@ default:
- Sylius\Bundle\MoneyBundle\Behat\MoneyContext
- Sylius\Bundle\ChannelBundle\Behat\ChannelContext
filters:
tags: "@legacy_taxonomies"
tags: "@legacy_taxonomy"

View file

@ -1,19 +1,19 @@
@legacy_products
Feature: Browsing products by taxonomies
Feature: Browsing products by taxons
In order to manage my products efficiently
As a store owner
I want to be able to view them by category
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| TRX1 | Category |
| TRX2 | Special |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > Shorts[TX3] |
And taxonomy "Special" has following taxons:
And taxon "Special" has following children:
| Featured[TX4] |
| New[TX5] |
And the following products exist:
@ -24,14 +24,14 @@ Feature: Browsing products by taxonomies
| Bambi Shorts | 35.00 | Shorts |
And I am logged in as administrator
Scenario: Seeing index of all products for given taxonomy
Given I am on the taxonomy index page
Scenario: Seeing index of all products for given taxon
Given I am on the taxon index page
And I follow "Category"
When I click "Browse products" near "T-Shirts"
Then I should see 2 products in the list
Scenario: Category does not contain any products
Given I am on the taxonomy index page
Given I am on the taxon index page
And I follow "Special"
When I click "Browse products" near "Featured"
Then I should see "There are no products to display"

View file

@ -31,14 +31,14 @@ Feature: Products
| TC1 | Clothing |
| TC2 | Electronics |
| TC3 | Print |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
| RTX2 | Special |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > Premium T-Shirts[TX3] |
And taxonomy "Special" has following taxons:
And taxon "Special" has following children:
| Featured[TX4] |
| New[TX5] |
And product "Sticker" has main taxon "New"
@ -233,9 +233,8 @@ Feature: Products
Scenario: Selecting the categorization taxons
Given I am editing product "Black T-Shirt"
And go to "Categorization" tab
When I select "Premium T-Shirts" from "Category"
And I select "Featured" from "Special"
And I additionally select "New" from "Special"
When I select "T-Shirts" from "Taxons"
And I additionally select "Featured" from "Taxons"
And I press "Save changes"
Then I should be on the page of product "Black T-Shirt"
And I should see "Product has been successfully updated"

View file

@ -6,10 +6,10 @@ Feature: Orm indexer event listener
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| TRX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
| Clothing[TX1] > Gloves[TX4] |
@ -22,7 +22,7 @@ Feature: Orm indexer event listener
| Doctrine T-Shirt | 15.00 | PHP T-Shirts | doctrine t-shirt |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
| taxon |
| Category |
And I am logged in as administrator

View file

@ -1,190 +0,0 @@
@legacy_taxonomies
Feature: taxonomies
In order to categorize my merchandise
As a store owner
I want to be able to manage taxonomies
Background:
Given store has default configuration
And there are following taxonomies defined:
| code | name |
| RTX1 | Category |
| RTX2 | Brand |
And taxonomy "Category" has following taxons:
| Electronics[TX1] > Featured[TX3] |
| Electronics[TX1] > Mac[TX4] > iMac[TX5] |
| Electronics[TX1] > Mac[TX4] > MBP[TX6] |
| Clothing[TX2] > Gloves[TX7] |
| Clothing[TX2] > Hats[TX8] |
And I am logged in as administrator
Scenario: Seeing index of all taxonomies
Given I am on the dashboard page
When I follow "Categorization"
Then I should be on the taxonomy index page
And I should see 2 taxonomies in the list
Scenario: Seeing empty index of taxonomies
Given there are no taxonomies
When I go to the taxonomy index page
Then I should see "There are no taxonomies defined"
Scenario: Accessing the taxonomy creation form
Given I am on the dashboard page
When I follow "Categorization"
And I follow "Create taxonomy"
Then I should be on the taxonomy creation page
Scenario: Submitting form without specifying the name
Given I am on the taxonomy creation page
When I press "Create"
Then I should still be on the taxonomy creation page
And I should see "Please enter taxonomy name"
Scenario: Creating new taxonomy
Given I am on the taxonomy creation page
When I fill in "Name" with "Vendor"
And I fill in "Code" with "RTX3"
And I press "Create"
Then I should be on the page of taxonomy "Vendor"
And I should see "Taxonomy has been successfully created"
Scenario: Created taxonomies appear in the list
Given I created taxonomy "Food" with code "RTX4"
When I go to the taxonomy index page
Then I should see 3 taxonomies in the list
And I should see taxonomy with name "Food" in that list
Scenario: Accessing the editing form from the list
Given I am on the taxonomy index page
When I click "Edit" near "Category"
Then I should be editing taxonomy "Category"
Scenario: Updating the taxonomy
Given I am editing taxonomy "Brand"
When I fill in "Name" with "Brands"
And I press "Save changes"
Then I should be on the page of taxonomy "Brands"
And I should see "Taxonomy has been successfully updated"
@javascript
Scenario: Deleting taxonomy
Given I am on the taxonomy index page
When I click "Delete" near "Brand"
And I click "Delete" from the confirmation modal
Then I should be on the taxonomy index page
And I should see "Taxonomy has been successfully deleted"
@javascript
Scenario: Deleted taxonomy disappears from the list
Given I am on the taxonomy index page
When I click "Delete" near "Category"
And I click "Delete" from the confirmation modal
Then I should be on the taxonomy index page
And I should not see taxonomy with name "Category" in that list
Scenario: Accessing taxonomy tree via the list
Given I am on the taxonomy index page
When I click "Category"
Then I should be on the page of taxonomy "Category"
Scenario: Seeing index of all taxonomy taxons
Given I am on the taxonomy index page
When I click "Category"
Then I should be on the page of taxonomy "Category"
And I should see 8 taxons in the list
Scenario: Creating new taxon under given taxonomy
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "Cars"
And I fill in "Code" with "TX9"
And I press "Create"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully created"
# TODO
# Scenario: Creating new taxon with existing name under given taxonomy
# Given I am on the page of taxonomy "Category"
# And I follow "Create taxon"
# When I fill in "Name" with "Electronics"
# And I press "Create"
# And I should see "Name already in use in the parent taxon"
Scenario: Creating new taxon with existing name under different taxon
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "Electronics"
And I fill in "Code" with "TX9"
And I select "Clothing" from "Parent"
And I press "Create"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully created"
And I should see 9 taxons in the list
Scenario: Creating new taxon with parent
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "iPods"
And I fill in "Code" with "TR9"
And I select "Electronics" from "Parent"
And I press "Create"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully created"
Scenario: Renaming the taxon
Given I am on the page of taxonomy "Category"
And I click "Edit" near "Clothing"
When I fill in "Name" with "Clothing and accessories"
And I press "Save changes"
Then I should be on the page of taxonomy "Category"
And I should see "Taxon has been successfully updated"
Scenario: Changing taxon slug
Given permalink of taxon "Clothing" in "Category" taxonomy has been changed to "super-clothing"
And I am on the page of taxonomy "Category"
When I click "Edit" near "Clothing"
Then I should see "category/super-clothing" in "Permalink" field
Scenario: Changing taxon slug with parent slug prefix
Given permalink of taxon "Clothing" in "Category" taxonomy has been changed to "category/super-clothing-category/best"
And I am on the page of taxonomy "Category"
When I click "Edit" near "Clothing"
Then I should see "category/super-clothing-category-best" in "Permalink" field
@javascript
Scenario: Deleting taxons
Given I am on the page of taxonomy "Category"
When I click "Delete" near "Electronics"
And I click "Delete" from the confirmation modal
Then I should still be on the page of taxonomy "Category"
And I should see "Taxon has been successfully deleted"
@javascript
Scenario: Deleted taxons disappear from the list
Given I am on the page of taxonomy "Category"
When I click "Delete" near "Clothing"
And I click "Delete" from the confirmation modal
Then I should still be on the page of taxonomy "Category"
And "Taxon has been successfully deleted" should appear on the page
And I should see 5 taxons in the list
Scenario: Cannot update taxon code
When I am editing taxon "Electronics" from taxonomy "Category"
Then the code field should be disabled
Scenario: Try create taxon with existing code
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "Cars"
And I fill in "Code" with "TX1"
And I press "Create"
Then I should still be on the taxon creation page from taxonomy "Category"
And I should see "Taxon with given code already exists"
Scenario: Try create taxon without code
Given I am on the page of taxonomy "Category"
And I follow "Create taxon"
When I fill in "Name" with "Cars"
And I press "Create"
Then I should still be on the taxon creation page from taxonomy "Category"
And I should see "Please enter taxon code"

View file

@ -0,0 +1,151 @@
@taxonomy
Feature: taxonomy
In order to categorize my merchandise
As a store owner
I want to be able to manage taxons
Background:
Given store has default configuration
And there are following taxons defined:
| code | name |
| RTX1 | Category |
| RTX2 | Brand |
And taxon "Category" has following children:
| Electronics[TX1] > Featured[TX3] |
| Electronics[TX1] > Mac[TX4] > iMac[TX5] |
| Electronics[TX1] > Mac[TX4] > MBP[TX6] |
| Clothing[TX2] > Gloves[TX7] |
| Clothing[TX2] > Hats[TX8] |
And I am logged in as administrator
Scenario: Seeing index of all taxons
Given I am on the dashboard page
When I follow "Taxons"
Then I should be on the taxon index page
And I should see 10 taxons in the list
Scenario: Seeing empty index of taxons
Given there are no taxons
When I go to the taxon index page
Then I should see "There are no taxons to display"
Scenario: Accessing the taxon creation form
Given I am on the dashboard page
When I follow "Taxons"
And I follow "Create taxon"
Then I should be on the taxon creation page
Scenario: Submitting form without specifying the name
Given I am on the taxon creation page
When I press "Create"
Then I should still be on the taxon creation page
And I should see "Please enter taxon name"
Scenario: Creating new taxon
Given I am on the taxon creation page
When I fill in "Name" with "Vendor"
And I fill in "Code" with "RTX3"
And I press "Create"
Then I should be on the taxon index page
And I should see "Taxon has been successfully created."
Scenario: Created taxons appear in the list
Given I created taxon "Food" with code "RTX4"
When I go to the taxon index page
Then I should see 11 taxons in the list
And I should see taxon with name "Food" in that list
Scenario: Accessing the editing form from the list
Given I am on the taxon index page
When I click "Edit" near "Category"
Then I should be editing taxon "Category"
Scenario: Updating the taxon
Given I am editing taxon "Brand"
When I fill in "Name" with "Brands"
And I press "Save changes"
Then I should be on the taxon index page
And I should see "Taxon has been successfully updated."
@javascript
Scenario: Deleting taxon
Given I am on the taxon index page
When I click "Delete" near "Brand"
And I click "Delete" from the confirmation modal
Then I should be on the taxon index page
And I should see "Taxon has been successfully deleted."
@javascript
Scenario: Deleted taxon disappears from the list
Given I am on the taxon index page
When I click "Delete" near "Electronics"
And I click "Delete" from the confirmation modal
Then I should be on the taxon index page
And I should not see taxon with name "Electronics" in that list
Scenario: Accessing taxon tree via the list
Given I am on the taxon index page
When I click "Category"
Then I should be on the page of taxon "Category"
Scenario: Seeing index of a taxons children
Given I am on the taxon index page
When I click "Category"
Then I should be on the page of taxon "Category"
And I should see 8 taxons in the list
Scenario: Creating new taxon with parent
Given I am on the page of taxon "Category"
And I follow "Create taxon"
When I fill in "Name" with "iPods"
And I fill in "Code" with "TR9"
And I select "Electronics" from "Parent"
And I press "Create"
Then I should be on the taxon index page
And I should see "Taxon has been successfully created."
Scenario: Renaming the taxon
Given I am on the page of taxon "Category"
And I click "Edit" near "Clothing"
When I fill in "Name" with "Clothing and accessories"
And I press "Save changes"
Then I should be on the taxon index page
And I should see "Taxon has been successfully updated."
@javascript
Scenario: Deleting taxons
Given I am on the page of taxon "Category"
When I click "Delete" near "Electronics"
And I click "Delete" from the confirmation modal
Then I should be on the taxon index page
And I should see "Taxon has been successfully deleted."
@javascript
Scenario: Deleted taxons disappear from the list
Given I am on the page of taxon "Category"
When I click "Delete" near "Clothing"
And I click "Delete" from the confirmation modal
Then I should be on the taxon index page
And "Taxon has been successfully deleted." should appear on the page
And I should see 6 taxons in the list
Scenario: Cannot update taxon code
When I am editing taxon "Electronics"
Then the code field should be disabled
Scenario: Try create taxon with existing code
Given I am on the page of taxon "Category"
And I follow "Create taxon"
When I fill in "Name" with "Cars"
And I fill in "Code" with "TX1"
And I press "Create"
Then I should still be on the taxon creation page
And I should see "Taxon with given code already exists."
Scenario: Try create taxon without code
Given I am on the page of taxon "Category"
And I follow "Create taxon"
When I fill in "Name" with "Cars"
And I press "Create"
Then I should still be on the taxon creation page
And I should see "Please enter taxon code."

View file

@ -1,5 +1,5 @@
@legacy_i18n
Feature: Taxonomies internationalization
Feature: Taxons internationalization
In order to improve the store SEO
As a store owner
I want to be able to have localised permalinks
@ -10,10 +10,10 @@ Feature: Taxonomies internationalization
| code |
| en_US |
| es_ES |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Shirts[TX2] > Long Sleeve[TX3] |
And the following taxon translations exist:
| taxon | name | locale |

View file

@ -5,10 +5,10 @@ Feature: Currency selection
I want to to select my currency in storefront
Background:
Given there are following taxonomies defined:
Given there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -6,10 +6,10 @@ Feature: Cart
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
And there are following options:
@ -26,7 +26,7 @@ Feature: Cart
And all products are available in all variations
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
| taxon |
| Category |
Scenario: Seeing empty cart

View file

@ -6,11 +6,12 @@ Feature: Tax included in price
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
And the following zones are defined:
| name | type | members |
| Germany | country | Germany |
@ -23,9 +24,9 @@ Feature: Tax included in price
And the following products exist:
| name | price | taxons | tax category |
| PHP Top | 85 | PHP T-Shirts | Taxable Goods |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon |
| Category |
And the default tax zone is "Germany"

View file

@ -9,17 +9,17 @@ Feature: Cart
And there are following users:
| email | password | enabled |
| bar@foo.com | foo1 | yes |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
| PHP Top | 85 | PHP T-Shirts |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
| taxon |
| Category |
Scenario: The cart is maintained after user log in

View file

@ -17,10 +17,10 @@ Feature: Checkout promotions with multiple rules and actions
| type | configuration |
| Fixed discount | Amount: 20 |
| Percentage discount | Percentage: 5 |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Debian T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -28,10 +28,10 @@ Feature: Checkout coupon promotions
And promotion "New Year campaign" has following coupons:
| code | usage limit | used |
| XD0002 | 1 | 1 |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX2 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Debian T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -20,10 +20,10 @@ Feature: Checkout limited time promotions
And promotion "Too soon" has following actions defined:
| type | configuration |
| Fixed discount | Amount: 40 |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Debian T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -10,10 +10,10 @@ Feature: Checkout fixed discount promotions
| name |
| Germany |
| Poland |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Ubuntu T-Shirts[TX2] |
| Clothing[TX1] > Debian T-Shirts[TX3] |
And the following products exist:
@ -52,10 +52,10 @@ Feature: Checkout fixed discount promotions
And promotion "Shipping to Germany" has following actions defined:
| type | configuration |
| Fixed discount | Amount: 40 |
And promotion "Ubuntu T-Shirts" has following rules defined:
| type | configuration |
| Taxonomy | Taxons: Ubuntu T-Shirts,Exclude: 0 |
And promotion "Ubuntu T-Shirts" has following actions defined:
And promotion "Ubuntu T-Shirts" has following rules defined:
| type | configuration |
| Taxon | Taxons: Ubuntu T-Shirts,Exclude: 0 |
And promotion "Ubuntu T-Shirts" has following actions defined:
| type | configuration |
| Fixed discount | Amount: 40 |
And promotion "3rd order" has following rules defined:

View file

@ -22,10 +22,10 @@ Feature: Checkout percentage discount promotions
And promotion "300 EUR" has following actions defined:
| type | configuration |
| Percentage discount | percentage: 10 |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Debian T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -22,10 +22,10 @@ Feature: Checkout usage limited promotions
And promotion "Free order with at least 3 items" has following actions defined:
| type | configuration |
| Percentage discount | Percentage: 100 |
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > Debian T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -6,10 +6,10 @@ Feature: Checkout addressing
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -6,10 +6,10 @@ Feature: Checkout addressing in preferred language
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |

View file

@ -6,13 +6,13 @@ Feature: Checkout finalization
Background:
Given store has default configuration
And there are following users:
| email | password | enabled |
| john@example.com | foo1 | yes |
And there are following taxonomies defined:
And there are following users:
| email | password | enabled |
| john@example.com | foo1 | yes |
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
@ -23,12 +23,12 @@ Feature: Checkout finalization
And the following shipping methods exist:
| code | zone | name |
| SM1 | UK | DHL Express |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon | payment | shipping |
| Category | Offline | DHL Express |
Scenario: Placing the order

View file

@ -6,10 +6,10 @@ Feature: Checkout inventory
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons | quantity |
@ -23,12 +23,12 @@ Feature: Checkout inventory
| SM1 | UK | DHL Express |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Credit Card | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
| Category | Credit Card | DHL Express |
And I am logged in as administrator
| PM1 | Credit Card | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon | payment | shipping |
| Category | Credit Card | DHL Express |
And I am logged in as administrator
Scenario: Inventory is updated after buying products
Given I added product "PHP Top" to cart, with quantity "4"

View file

@ -6,10 +6,10 @@ Feature: Checkout Payment
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
@ -21,14 +21,14 @@ Feature: Checkout Payment
| code | zone | name |
| SM1 | UK | DHL Express |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Credit Card | stripe | yes |
| PM2 | PayPal | paypal | yes |
| PM3 | PayPal PRO | paypal_pro | no |
| code | name | gateway | enabled |
| PM1 | Credit Card | stripe | yes |
| PM2 | PayPal | paypal | yes |
| PM3 | PayPal PRO | paypal_pro | no |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
| Category | PayPal, PayPal PRO, Credit Card | DHL Express |
| taxon | payment | shipping |
| Category | PayPal, PayPal PRO, Credit Card | DHL Express |
And I am logged in user
And I added product "PHP Top" to cart
And I go to the checkout start page

View file

@ -6,10 +6,10 @@ Feature: Checkout security
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
@ -24,15 +24,15 @@ Feature: Checkout security
And the following shipping methods exist:
| code | zone | name |
| SM1 | UK | DHL Express |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon | payment | shipping |
| Category | Offline | DHL Express |
And I added product "PHP Top" to cart
And I go to the checkout start page
And I added product "PHP Top" to cart
And I go to the checkout start page
Scenario: Trying to sign in with bad credentials
during the checkout

View file

@ -6,10 +6,10 @@ Feature: Checkout shipping
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
@ -30,15 +30,15 @@ Feature: Checkout shipping
| SM2 | USA | FedEx | Flat rate | Amount: 6500 | yes |
| SM3 | USA | FedEx Premium | Flat rate | Amount: 10000 | yes |
| SM4 | UK + Germany | UPS Ground | Flat rate | Amount: 20000 | no |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon | payment | shipping |
| Category | Offline | DHL Express, FedEx, FedEx Premium, UPS Ground |
And I am logged in user
And I added product "PHP Top" to cart
And I am logged in user
And I added product "PHP Top" to cart
Scenario: Only enabled and available methods are displayed to user for zone
depending on the shipping address zone

View file

@ -6,10 +6,10 @@ Feature: Checkout shipping in preferred language
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following products exist:
| name | price | taxons |
@ -34,8 +34,8 @@ Feature: Checkout shipping in preferred language
And the shipping method translations exist:
| shipping method | name | locale |
| UPS Ground | UPS Land | de_DE |
And the default channel has following configuration:
| taxonomy | shipping |
And the default channel has following configuration:
| taxon | shipping |
| Category | FedEx, UPS Ground |
And I am logged in user
And I added product "PHP Top" to cart

View file

@ -6,10 +6,10 @@ Feature: Checkout starting
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
And there are following options:

View file

@ -6,10 +6,10 @@ Feature: Checkout taxation
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
| RTX1 | Category |
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following zones are defined:
| name | type | members |
@ -26,16 +26,16 @@ Feature: Checkout taxation
And the following shipping methods exist:
| code | zone | name | tax category | calculator | configuration |
| SM1 | UK | DHL Express | Taxable Goods | Flat rate | Amount: 5000 |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy | payment | shipping |
And the following payment methods exist:
| code | name | gateway | enabled |
| PM1 | Offline | offline | yes |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon | payment | shipping |
| Category | Offline | DHL Express |
And I am logged in user
And I added product "PHP Top" to cart
And I go to the checkout start page
And I am logged in user
And I added product "PHP Top" to cart
And I go to the checkout start page
Scenario: Placing the order
Given I fill in the shipping address to United Kingdom

View file

@ -6,10 +6,10 @@ Feature: Products
Background:
Given there is default currency configured
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
| Clothing[TX1] > Gloves[TX4] |
@ -27,8 +27,8 @@ Feature: Products
| Sylius Tee | 12.99 | PHP T-Shirts | | | |
| Symfony T-Shirt | 15.00 | PHP T-Shirts | | | |
| Doctrine T-Shirt | 15.00 | PHP T-Shirts | | | |
And channel "WEB-EU" has following configuration:
| taxonomy |
And channel "WEB-EU" has following configuration:
| taxon |
| Category |
And channel "WEB-EU" has following products assigned:
| product |

View file

@ -6,10 +6,10 @@ Feature: Browse products, categories, attributes and options in preferred langua
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
And there are following options:
@ -30,11 +30,9 @@ Feature: Browse products, categories, attributes and options in preferred langua
And the following product translations exist:
| product | name | locale |
| Super T-Shirt | Camiseta Super | es_ES |
And the following taxonomy translations exist:
| taxonomy | name | locale |
| Category | Categoria | es_ES |
And the following taxon translations exist:
| taxon | name | locale |
| Category | Categoria | es_ES |
| Clothing | Ropa | es_ES |
| T-Shirts | Camisetas | es_ES |
And the following attribute translations exist:

View file

@ -6,10 +6,11 @@ Feature: Search products
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > T-Shirts[TX2] |
| Clothing[TX1] > PHP T-Shirts[TX3] |
| Clothing[TX1] > Gloves[TX4] |
@ -20,9 +21,9 @@ Feature: Search products
| Sylius Tee | 12.99 | PHP T-Shirts | a very nice php t-shirt |
| Symfony T-Shirt | 15.00 | PHP T-Shirts | symfony t-shirt |
| Doctrine T-Shirt | 15.00 | PHP T-Shirts | doctrine t-shirt |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon |
| Category |
And I populate the index

View file

@ -6,10 +6,10 @@ Feature: Group based pricing
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following zones are defined:
| name | type | members |
@ -37,9 +37,9 @@ Feature: Group based pricing
| group | price |
| Wholesale Customers | 39.49 |
| Retail Customers | 45.99 |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon |
| Category |
Scenario: Default price is used when user is not logged in

View file

@ -6,10 +6,10 @@ Feature: Standard pricing
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following zones are defined:
| name | type | members |
@ -25,9 +25,9 @@ Feature: Standard pricing
| name | price | taxons | tax category |
| PHP Top | 49.99 | PHP T-Shirts | Taxable Goods |
| Symfony Tee | 69.00 | PHP T-Shirts | Taxable Goods |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxonomy |
And all products are assigned to the default channel
And the default channel has following configuration:
| taxon |
| Category |
Scenario: Flat price is calculated for products

View file

@ -6,10 +6,10 @@ Feature: Volume based pricing
Background:
Given store has default configuration
And there are following taxonomies defined:
And there are following taxons defined:
| code | name |
| RTX1 | Category |
And taxonomy "Category" has following taxons:
And taxon "Category" has following children:
| Clothing[TX1] > PHP T-Shirts[TX2] |
And the following zones are defined:
| name | type | members |

View file

@ -21,13 +21,9 @@ sylius_api_product_archetype:
resource: @SyliusApiBundle/Resources/config/routing/product_archetype.yml
prefix: /product-archetypes
sylius_api_taxonomy:
resource: @SyliusApiBundle/Resources/config/routing/taxonomy.yml
prefix: /taxonomies
sylius_api_taxon:
resource: @SyliusApiBundle/Resources/config/routing/taxon.yml
prefix: /taxonomies/{taxonomyId}/taxons
prefix: /taxons
sylius_api_order:
resource: @SyliusApiBundle/Resources/config/routing/order.yml

View file

@ -9,19 +9,12 @@ sylius_api_taxon_index:
paginate: $limit
sortable: true
filterable: true
criteria:
taxonomy: $taxonomyId
sylius_api_taxon_show:
path: /{id}
methods: [GET]
defaults:
_controller: sylius.controller.taxon:showAction
_sylius:
filterable: true
criteria:
taxonomy: $taxonomyId
id: $id
sylius_api_taxon_create:
path: /

View file

@ -1,35 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius_api_taxonomy_index:
path: /
methods: [GET]
defaults:
_controller: sylius.controller.taxonomy:indexAction
_sylius:
paginate: $limit
sortable: true
sylius_api_taxonomy_create:
path: /
methods: [POST]
defaults:
_controller: sylius.controller.taxonomy:createAction
sylius_api_taxonomy_update:
path: /{id}
methods: [PUT, PATCH]
defaults:
_controller: sylius.controller.taxonomy:updateAction
sylius_api_taxonomy_delete:
path: /{id}
methods: [DELETE]
defaults:
_controller: sylius.controller.taxonomy:deleteAction
sylius_api_taxonomy_show:
path: /{id}
methods: [GET]
defaults:
_controller: sylius.controller.taxonomy:showAction

View file

@ -128,7 +128,7 @@ class ChannelContext extends DefaultContext
isset($data['currencies']) ? $data['currencies'] : null,
isset($data['shipping']) ? $data['shipping'] : null,
isset($data['payment']) ? $data['payment'] : null,
isset($data['taxonomy']) ? $data['taxonomy'] : null
isset($data['taxon']) ? $data['taxon'] : null
);
}
@ -165,7 +165,7 @@ class ChannelContext extends DefaultContext
return $channel;
}
private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null, $taxonomyNames = null)
private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null, $taxonNames = null)
{
if ($shippingMethodNames) {
$shippingMethodNames = array_map('trim', explode(',', $shippingMethodNames));
@ -199,12 +199,11 @@ class ChannelContext extends DefaultContext
}
}
if ($taxonomyNames) {
$taxonomyNames = array_map('trim', explode(',', $taxonomyNames));
foreach ($taxonomyNames as $taxonomyName) {
$taxonomy = $this->getRepository('taxonomy')->findOneBy(['name' => $taxonomyName]);
$channel->addTaxonomy($taxonomy);
if ($taxonNames) {
$taxonNames = array_map('trim', explode(',', $taxonNames));
foreach ($taxonNames as $taxonName) {
$taxon = $this->getRepository('taxon')->findOneBy(['name' => $taxonName]);
$channel->addTaxon($taxon);
}
}
}

View file

@ -16,7 +16,6 @@ use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Uploader\ImageUploaderInterface;
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
class ImageUploadListener
@ -66,20 +65,4 @@ class ImageUploadListener
$this->uploader->upload($subject);
}
}
public function uploadTaxonomyImage(GenericEvent $event)
{
$subject = $event->getSubject();
if (!$subject instanceof TaxonomyInterface) {
throw new UnexpectedTypeException(
$subject,
'Sylius\Component\Taxonomy\Model\TaxonomyInterface'
);
}
if ($subject->getRoot()->hasFile()) {
$this->uploader->upload($subject->getRoot());
}
}
}

View file

@ -29,8 +29,8 @@ class ChannelType extends BaseChannelType
parent::buildForm($builder, $options);
$builder
->add('taxonomies', 'sylius_taxonomy_choice', [
'label' => 'sylius.form.channel.taxonomies',
->add('taxons', 'sylius_taxon_choice', [
'label' => 'sylius.form.channel.taxons',
'multiple' => true,
])
->add('locales', 'sylius_locale_choice', [

View file

@ -39,7 +39,10 @@ class ProductType extends BaseProductType
'empty_value' => '---',
'label' => 'sylius.form.product.shipping_category',
])
->add('taxons', 'sylius_taxon_selection')
->add('taxons', 'sylius_taxon_choice', array(
'label' => 'sylius.form.product.taxons',
'multiple' => true,
))
->add('variantSelectionMethod', 'choice', [
'label' => 'sylius.form.product.variant_selection_method',
'choices' => Product::getVariantSelectionMethodLabels(),

View file

@ -17,7 +17,7 @@ use Symfony\Component\Form\FormBuilderInterface;
/**
* @author Saša Stamenković <umpirsky@gmail.com>
*/
class TaxonomyConfigurationType extends AbstractType
class TaxonConfigurationType extends AbstractType
{
/**
* {@inheritdoc}
@ -25,11 +25,8 @@ class TaxonomyConfigurationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('taxons', 'sylius_taxon_selection', [
'label' => 'sylius.form.rule.taxonomy_configuration.taxons',
'model_transformer' => [
'save_objects' => false,
],
->add('taxons', 'sylius_taxon_choice', [
'label' => 'sylius.form.rule.taxon_configuration.taxons',
])
->add('exclude', 'checkbox', [
'label' => 'sylius.form.rule.taxonomy_configuration.exclude',
@ -42,6 +39,6 @@ class TaxonomyConfigurationType extends AbstractType
*/
public function getName()
{
return 'sylius_promotion_rule_taxonomy_configuration';
return 'sylius_promotion_rule_taxon_configuration';
}
}

View file

@ -1,38 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\CoreBundle\Form\Type;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyType as BaseTaxonomyType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Taxonomy form type.
*/
class TaxonomyType extends BaseTaxonomyType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->add(
'file',
'file',
[
'property_path' => 'root.file',
'label' => 'sylius.form.taxonomy.file',
]
);
}
}

View file

@ -75,11 +75,6 @@ sylius_content:
sylius_taxonomy:
resources:
taxonomy:
classes:
model: Sylius\Component\Core\Model\Taxonomy
form:
default: Sylius\Bundle\CoreBundle\Form\Type\TaxonomyType
taxon:
classes:
model: Sylius\Component\Core\Model\Taxon
@ -260,7 +255,7 @@ sylius_search:
filters:
pre_search_filter:
enabled: true
taxonomy: category
taxon: CATEGORY
facet_groups:
search_set:
values: [taxons, price, made_of, color]
@ -416,13 +411,6 @@ sylius_rbac:
sylius.product_variant.update: Edit product variant
sylius.product_variant.delete: Delete product variant
sylius.manage.taxonomy: Manage taxonomies
sylius.taxonomy.show: Show taxonomy
sylius.taxonomy.index: List taxonomies
sylius.taxonomy.create: Create taxonomy
sylius.taxonomy.update: Edit taxonomy
sylius.taxonomy.delete: Delete taxonomy
sylius.manage.taxon: Manage taxons
sylius.taxon.show: Show taxon
sylius.taxon.index: List taxons
@ -695,7 +683,6 @@ sylius_rbac:
sylius.manage.product_option: [sylius.product_option.show, sylius.product_option.index, sylius.product_option.create, sylius.product_option.update, sylius.product_option.delete]
sylius.manage.product_archetype: [sylius.product_archetype.show, sylius.product_archetype.index, sylius.product_archetype.create, sylius.product_archetype.update, sylius.product_archetype.delete]
sylius.manage.product_variant: [sylius.product_variant.show, sylius.product_variant.index, sylius.product_variant.create, sylius.product_variant.update, sylius.product_variant.delete]
sylius.manage.taxonomy: [sylius.taxonomy.show, sylius.taxonomy.index, sylius.taxonomy.create, sylius.taxonomy.update, sylius.taxonomy.delete]
sylius.manage.taxon: [sylius.taxon.show, sylius.taxon.index, sylius.taxon.create, sylius.taxon.update, sylius.taxon.delete]
sylius.manage.adjustment: [sylius.adjustment.show, sylius.adjustment.index, sylius.adjustment.create, sylius.adjustment.update, sylius.adjustment.delete]
sylius.manage.order: [sylius.order.show, sylius.order.index, sylius.order.create, sylius.order.update, sylius.order.delete]
@ -731,7 +718,7 @@ sylius_rbac:
sylius.manage.contact_topic: [sylius.contact_topic.show, sylius.contact_topic.index, sylius.contact_topic.create, sylius.contact_topic.update, sylius.contact_topic.delete]
sylius.manage.settings: [sylius.settings.sylius_general, sylius.settings.sylius_security, sylius.settings.sylius_taxation]
sylius.manage.product_association_type: [sylius.product_association_type.show, sylius.product_association_type.index, sylius.product_association_type.create, sylius.product_association_type.update, sylius.product_association_type.delete]
sylius.catalog: [sylius.manage.product, sylius.manage.product_attribute, sylius.manage.product_option, sylius.manage.product_archetype, sylius.manage.product_variant, sylius.manage.taxonomy, sylius.manage.taxon, sylius.manage.metadata_container, sylius.manage.product_association_type]
sylius.catalog: [sylius.manage.product, sylius.manage.product_attribute, sylius.manage.product_option, sylius.manage.product_archetype, sylius.manage.product_variant, sylius.manage.taxon, sylius.manage.metadata_container, sylius.manage.product_association_type]
sylius.marketing: [sylius.manage.promotion, sylius.manage.promotion_coupon, sylius.manage.email, sylius.manage.metadata_container]
sylius.sales: [sylius.manage.adjustment, sylius.manage.order, sylius.manage.order_item, sylius.manage.adjustment, sylius.manage.payment, sylius.manage.report, sylius.manage.product_review]
sylius.shipping: [sylius.manage.shipment, sylius.manage.shipping_method, sylius.manage.shipping_category]

View file

@ -66,13 +66,13 @@
</inverse-join-columns>
</join-table>
</many-to-many>
<many-to-many field="taxonomies" target-entity="Sylius\Component\Taxonomy\Model\TaxonomyInterface">
<join-table name="sylius_channel_taxonomy">
<many-to-many field="taxons" target-entity="Sylius\Component\Taxonomy\Model\TaxonInterface">
<join-table name="sylius_channel_taxon">
<join-columns>
<join-column name="channel_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</join-columns>
<inverse-join-columns>
<join-column name="taxonomy_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
<join-column name="taxon_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</inverse-join-columns>
</join-table>
</many-to-many>

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Core\Model\Taxonomy" table="sylius_taxonomy" />
</doctrine-mapping>

View file

@ -43,7 +43,7 @@
<parameter key="sylius.form.type.promotion_rule.nth_order_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\NthOrderConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.customer_loyalty_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\CustomerLoyaltyConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.shipping_country_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\ShippingCountryConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.taxonomy_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\TaxonomyConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.taxon_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\TaxonConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.contains_product_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\ContainsProductConfigurationType</parameter>
<parameter key="sylius.form.type.promotion_rule.customer_group_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Rule\CustomerGroupType</parameter>
<parameter key="sylius.form.type.promotion_action.shipping_discount_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Action\ShippingDiscountConfigurationType</parameter>
@ -139,8 +139,8 @@
<argument>%sylius.model.country.class%</argument>
<tag name="form.type" alias="sylius_promotion_rule_shipping_country_configuration" />
</service>
<service id="sylius.form.type.promotion_rule.taxonomy_configuration" class="%sylius.form.type.promotion_rule.taxonomy_configuration.class%">
<tag name="form.type" alias="sylius_promotion_rule_taxonomy_configuration" />
<service id="sylius.form.type.promotion_rule.taxon_configuration" class="%sylius.form.type.promotion_rule.taxon_configuration.class%">
<tag name="form.type" alias="sylius_promotion_rule_taxon_configuration" />
</service>
<service id="sylius.form.type.promotion_rule.contains_product_configuration" class="%sylius.form.type.promotion_rule.contains_product_configuration.class%">
<argument type="service" id="sylius.repository.product_variant" />

View file

@ -1,2 +0,0 @@
Sylius\Component\Core\Model\Taxonomy:
exclusion_policy: ALL

View file

@ -69,7 +69,7 @@
<parameter key="sylius.promotion_rule_checker.nth_order.class">Sylius\Component\Core\Promotion\Checker\NthOrderRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.customer_loyalty.class">Sylius\Component\Core\Promotion\Checker\CustomerLoyaltyRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.shipping_country.class">Sylius\Component\Core\Promotion\Checker\ShippingCountryRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.taxonomy.class">Sylius\Component\Core\Promotion\Checker\TaxonomyRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.taxon.class">Sylius\Component\Core\Promotion\Checker\TaxonRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.contains_product.class">Sylius\Component\Core\Promotion\Checker\ContainsProductRuleChecker</parameter>
<parameter key="sylius.promotion_rule_checker.customer_group.class">Sylius\Component\Core\Promotion\Checker\CustomerGroupRuleChecker</parameter>
<parameter key="sylius.promotion_action.fixed_discount.class">Sylius\Component\Core\Promotion\Action\FixedDiscountAction</parameter>
@ -394,8 +394,6 @@
<tag name="kernel.event_listener" event="sylius.product_variant.pre_update" method="uploadProductImage" />
<tag name="kernel.event_listener" event="sylius.taxon.pre_create" method="uploadTaxonImage" />
<tag name="kernel.event_listener" event="sylius.taxon.pre_update" method="uploadTaxonImage" />
<tag name="kernel.event_listener" event="sylius.taxonomy.pre_create" method="uploadTaxonomyImage" />
<tag name="kernel.event_listener" event="sylius.taxonomy.pre_update" method="uploadTaxonomyImage" />
</service>
<service id="sylius.listener.product_delete" class="%sylius.listener.product_delete.class%">
@ -422,8 +420,8 @@
<argument type="service" id="sylius.repository.country" />
<tag name="sylius.promotion_rule_checker" type="shipping_country" label="Shipping country" />
</service>
<service id="sylius.promotion_rule_checker.taxonomy" class="%sylius.promotion_rule_checker.taxonomy.class%">
<tag name="sylius.promotion_rule_checker" type="taxonomy" label="Taxonomy" />
<service id="sylius.promotion_rule_checker.taxon" class="%sylius.promotion_rule_checker.taxon.class%">
<tag name="sylius.promotion_rule_checker" type="taxon" label="Taxon" />
</service>
<service id="sylius.promotion_rule_checker.contains_product" class="%sylius.promotion_rule_checker.contains_product.class%">
<tag name="sylius.promotion_rule_checker" type="contains_product" label="Contains Product" />

View file

@ -71,7 +71,7 @@ class ProductTypeSpec extends ObjectBehavior
->willReturn($builder)
;
$builder
->add('taxons', 'sylius_taxon_selection', Argument::any())
->add('taxons', 'sylius_taxon_choice', Argument::any())
->shouldBeCalled()
->willReturn($builder)
;

View file

@ -1,39 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\CoreBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyType;
use Symfony\Component\Form\FormTypeInterface;
class TaxonomyTypeSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('Taxonomy', ['sylius']);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\CoreBundle\Form\Type\TaxonomyType');
}
function it_should_be_a_form_type()
{
$this->shouldImplement(FormTypeInterface::class);
}
function it_should_extend_Sylius_taxon_base_form_type()
{
$this->shouldHaveType(TaxonomyType::class);
}
}

View file

@ -47,13 +47,13 @@ class LoadChannelData extends DataFixture
* @param string $url
* @param array $locales
* @param array $currencies
* @param array $taxonomies
* @param array $taxons
* @param array $shippingMethods
* @param array $paymentMethods
*
* @return ChannelInterface
*/
protected function createChannel($code, $name, $url, array $locales = [], array $currencies = [], array $taxonomies = [], array $shippingMethods = [], array $paymentMethods = [])
protected function createChannel($code, $name, $url, array $locales = [], array $currencies = [], array $taxons = [], array $shippingMethods = [], array $paymentMethods = [])
{
/** @var ChannelInterface $channel */
$channel = $this->getChannelFactory()->createNew();
@ -70,8 +70,8 @@ class LoadChannelData extends DataFixture
foreach ($currencies as $currency) {
$channel->addCurrency($this->getReference('Sylius.Currency.'.$currency));
}
foreach ($taxonomies as $taxonomy) {
$channel->addTaxonomy($this->getReference('Sylius.Taxonomy.'.$taxonomy));
foreach ($taxons as $taxon) {
$channel->addTaxon($this->getReference('Sylius.Taxon.'.$taxon));
}
foreach ($shippingMethods as $shippingMethod) {
$channel->addShippingMethod($this->getReference('Sylius.ShippingMethod.'.$shippingMethod));

View file

@ -14,23 +14,22 @@ namespace Sylius\Bundle\FixturesBundle\DataFixtures\ORM;
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Bundle\FixturesBundle\DataFixtures\DataFixture;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
/**
* Default taxonomies to play with Sylius.
* Default taxons to play with Sylius.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class LoadTaxonomiesData extends DataFixture
class LoadTaxonsData extends DataFixture
{
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$manager->persist($this->createTaxonomy(
'RTX1', [$this->defaultLocale => 'Category', 'es_ES' => 'Categoria'],
$manager->persist($this->createTaxons(
'CATEGORY', [$this->defaultLocale => 'Category', 'es_ES' => 'Categoria'],
[
['code' => 'TX1', 'locales' => [$this->defaultLocale => 'T-Shirts', 'es_ES' => 'Camisetas']],
['code' => 'TX2', 'locales' => [$this->defaultLocale => 'Stickers', 'es_ES' => 'Pegatinas']],
@ -38,8 +37,8 @@ class LoadTaxonomiesData extends DataFixture
['code' => 'TX4', 'locales' => [$this->defaultLocale => 'Books', 'es_ES' => 'Libros']],
]));
$manager->persist($this->createTaxonomy(
'RTX2', [$this->defaultLocale => 'Brand', 'es_ES' => 'Marca'],
$manager->persist($this->createTaxons(
'BRAND', [$this->defaultLocale => 'Brand', 'es_ES' => 'Marca'],
[
['code' => 'TX5', 'locales' => [$this->defaultLocale => 'SuperTees', 'es_ES' => 'SuperCamisetas']],
['code' => 'TX6', 'locales' => [$this->defaultLocale => 'Stickypicky', 'es_ES' => 'Pegapicky']],
@ -59,36 +58,35 @@ class LoadTaxonomiesData extends DataFixture
}
/**
* Create and save taxonomy with given taxons.
* Create and save taxon with given taxons.
*
* @param array $taxonomyName
* @param array $taxonsArray
* @param string $code
* @param array $rootTaxonName
* @param array $childrenArray
*
* @internal param string $name
* @internal param array $taxons
*
* @return TaxonomyInterface
* @return TaxonInterface
*/
protected function createTaxonomy($code, array $taxonomyName, array $taxonsArray)
protected function createTaxons($code, array $rootTaxonName, array $childrenArray)
{
/* @var $taxonomy TaxonomyInterface */
$taxonomy = $this->getTaxonomyFactory()->createNew();
$taxonomy->getRoot()->setCode($code);
/* @var $rootTaxon TaxonInterface */
$rootTaxon = $this->getTaxonFactory()->createNew();
$rootTaxon->setCode($code);
foreach ($taxonomyName as $locale => $name) {
$taxonomy->setCurrentLocale($locale);
$taxonomy->setFallbackLocale($locale);
$taxonomy->setName($name);
foreach ($rootTaxonName as $locale => $name) {
$rootTaxon->setCurrentLocale($locale);
$rootTaxon->setFallbackLocale($locale);
$rootTaxon->setName($name);
if ($this->defaultLocale === $locale) {
$this->setReference('Sylius.Taxonomy.'.$name, $taxonomy);
$this->setReference('Sylius.Taxon.'.$name, $rootTaxon);
}
}
foreach ($taxonsArray as $taxonArray) {
foreach ($childrenArray as $taxonArray) {
/* @var $taxon TaxonInterface */
$taxon = $this->getTaxonFactory()->createNew();
$taxon->setCode($taxonArray['code']);
foreach ($taxonArray['locales'] as $locale => $taxonName) {
$taxon->setCurrentLocale($locale);
$taxon->setFallbackLocale($locale);
@ -99,9 +97,10 @@ class LoadTaxonomiesData extends DataFixture
$this->setReference('Sylius.Taxon.'.$taxonName, $taxon);
}
}
$taxonomy->addTaxon($taxon);
$rootTaxon->addChild($taxon);
}
return $taxonomy;
return $rootTaxon;
}
}

View file

@ -7,6 +7,7 @@ sylius:
options: Options
meta_keywords: Meta keywords
meta_description: Meta description
taxons: Taxons
product_variant:
available_on: Available on
available_until: Available until

View file

@ -702,15 +702,4 @@ class WebContext extends DefaultContext
throw new \Exception(sprintf('"%s" %s should be disabled', $name, $fieldType));
}
}
/**
* @Given /^permalink of taxon "([^"]*)" in "([^"]*)" taxonomy has been changed to "([^"]*)"$/
*/
public function permalinkOfTaxonInTaxonomyHasBeenChangedTo($taxon, $taxonomy, $newPermalink)
{
$this->iAmOnTheResourcePage('taxonomy', 'name', $taxonomy);
$this->iClickNear('Edit', $taxon);
$this->fillField('Permalink', $newPermalink);
$this->pressButton('Save changes');
}
}

View file

@ -14,6 +14,7 @@ namespace Sylius\Bundle\SearchBundle\Controller;
use FOS\RestBundle\View\View;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Bundle\SearchBundle\Query\SearchStringQuery;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -91,15 +92,14 @@ class SearchController extends ResourceController
$filters = [];
if ($this->container->getParameter('sylius_search.pre_search_filter.enabled')) {
$taxonomy = $this->container->get('sylius.repository.taxonomy')
->findOneBy([
'name' => strtoupper($this->container->getParameter('sylius_search.pre_search_filter.taxon')),
])
;
$rootTaxon = $this->get('sylius.repository.taxon')->findOneBy([
'code' => $this->container->getParameter('sylius_search.pre_search_filter.taxon'),
]);
$filters = [];
if ($taxonomy) {
foreach ($taxonomy->getTaxons() as $taxon) {
$filters = array();
if ($rootTaxon) {
/** @var TaxonInterface $rootTaxon */
foreach ($rootTaxon->getChildren() as $taxon) {
$filters[] = $taxon->getName();
}
}

View file

@ -74,7 +74,7 @@ class Configuration implements ConfigurationInterface
->arrayNode('pre_search_filter')
->isRequired()
->children()
->scalarNode('taxonomy')
->scalarNode('taxon')
->isRequired()
->cannotBeEmpty()
->end()

View file

@ -50,7 +50,7 @@ class SyliusSearchExtension extends AbstractResourceExtension
$container->setParameter('sylius_search.request.method', $config['request_method']);
$container->setParameter('sylius_search.search.template', $config['search_form_template']);
$container->setParameter('sylius_search.pre_search_filter.enabled', $config['filters']['pre_search_filter']['enabled']);
$container->setParameter('sylius_search.pre_search_filter.taxon', $config['filters']['pre_search_filter']['taxonomy']);
$container->setParameter('sylius_search.pre_search_filter.taxon', $config['filters']['pre_search_filter']['taxon']);
$container->setParameter('sylius_search.custom.accessor.class', $config['custom_accessor']);
}

View file

@ -154,7 +154,7 @@ fos_elastica:
filters:
search_filter: # the small drop down menu on the side of the search field
enabled: true
taxonomy: category # possible values are the high level taxons (category, brand for sylius)
taxon: CATEGORY # possible values are taxons codes (CATEGORY, BRAND for sylius)
facet_groups: # possible facet groups, you assign them in a finder object
search_set:
values: [taxons, price, made_of, color]

View file

@ -18,96 +18,76 @@ use Sylius\Component\Taxonomy\Model\TaxonInterface;
class TaxonomyContext extends DefaultContext
{
/**
* @Given /^there are following taxonomies defined:$/
* @Given /^there are following taxons defined:$/
*/
public function thereAreFollowingTaxonomies(TableNode $table)
public function thereAreFollowingTaxons(TableNode $table)
{
foreach ($table->getHash() as $data) {
$this->thereIsTaxonomy($data['name'], $data['code'], false);
$this->thereIsTaxon($data['name'], $data['code'], false);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^I created taxonomy "([^""]*)" with code "([^""]*)"$/
* @Given /^I created taxon "([^""]*)" with code "([^""]*)"$/
*/
public function thereIsTaxonomy($name, $code, $flush = true)
public function thereIsTaxon($name, $code, $flush = true)
{
$taxonomy = $this->getFactory('taxonomy')->createNew();
$taxonomy->getRoot()->setCode($code);
$taxonomy->setName($name);
/** @var TaxonInterface $taxon */
$taxon = $this->getFactory('taxon')->createNew();
$taxon->setName($name);
$taxon->setCode($code);
if (null === $taxonomy->getCurrentLocale()) {
$taxonomy->setCurrentLocale('en_US');
}
$this->getEntityManager()->persist($taxonomy);
$this->getEntityManager()->persist($taxon);
if ($flush) {
$this->getEntityManager()->flush();
}
}
/**
* @Given /^taxonomy "([^""]*)" has following taxons:$/
* @Given /^taxon "([^""]*)" has following children:$/
*/
public function taxonomyHasFollowingTaxons($taxonomyName, TableNode $taxonsTable)
public function taxonHasFollowingChildren($taxonName, TableNode $childrenTable)
{
$taxonomy = $this->findOneByName('taxonomy', $taxonomyName);
/* @var $taxon TaxonInterface */
$taxon = $this->findOneByName('taxon', $taxonName);
$manager = $this->getEntityManager();
$taxons = [];
$children = array();
foreach ($taxonsTable->getRows() as $node) {
foreach ($childrenTable->getRows() as $node) {
$taxonList = explode('>', $node[0]);
/* @var $parent TaxonInterface */
$parent = null;
foreach ($taxonList as $taxon) {
$taxon = trim($taxon);
$taxonData = preg_split('[\\[|\\]]', $taxon, -1, PREG_SPLIT_NO_EMPTY);
foreach ($taxonList as $item) {
$item = trim($item);
$childData = preg_split("[\\[|\\]]", $item, -1, PREG_SPLIT_NO_EMPTY);
if (!isset($taxons[$taxonData[0]])) {
/* @var $taxon TaxonInterface */
$taxon = $this->getFactory('taxon')->createNew();
$taxon->setName($taxonData[0]);
$taxon->setCode($taxonData[1]);
if (!isset($children[$childData[0]])) {
/* @var $child TaxonInterface */
$child = $this->getFactory('taxon')->createNew();
$child->setName($childData[0]);
$child->setCode($childData[1]);
$taxons[$taxonData[0]] = $taxon;
$children[$childData[0]] = $child;
}
$taxon = $taxons[$taxonData[0]];
$child = $children[$childData[0]];
if (null !== $parent) {
$parent->addChild($taxon);
$parent->addChild($child);
} else {
$taxonomy->addTaxon($taxon);
$taxon->addChild($child);
}
$parent = $taxon;
$parent = $child;
}
}
$manager->persist($taxonomy);
$manager->flush();
}
/**
* @Given the following taxonomy translations exist:
*/
public function theFollowingTaxonomyTranslationsExist(TableNode $table)
{
$manager = $this->getEntityManager();
foreach ($table->getHash() as $data) {
$taxonomyTranslation = $this->findOneByName('taxonomy_translation', $data['taxonomy']);
$taxonomy = $taxonomyTranslation->getTranslatable();
$taxonomy->setCurrentLocale($data['locale']);
$taxonomy->setFallbackLocale($data['locale']);
$taxonomy->setName($data['name']);
}
$manager->persist($taxon);
$manager->flush();
}
@ -119,6 +99,7 @@ class TaxonomyContext extends DefaultContext
foreach ($table->getHash() as $data) {
$taxonTranslation = $this->findOneByName('taxon_translation', $data['taxon']);
/** @var TaxonInterface $taxon */
$taxon = $taxonTranslation->getTranslatable();
$taxon->setCurrentLocale($data['locale']);
$taxon->setFallbackLocale($data['locale']);

View file

@ -12,23 +12,15 @@
namespace Sylius\Bundle\TaxonomyBundle\DependencyInjection;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceChoiceType;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyTranslationType;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyType;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonTranslationType;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonType;
use Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonTranslationType;
use Sylius\Component\Resource\Factory\Factory;
use Sylius\Component\Taxonomy\Factory\TaxonFactory;
use Sylius\Component\Taxonomy\Factory\TaxonomyFactory;
use Sylius\Component\Taxonomy\Model\Taxon;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\Taxonomy;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyTranslation;
use Sylius\Component\Taxonomy\Model\TaxonomyTranslationInterface;
use Sylius\Component\Taxonomy\Model\TaxonTranslation;
use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface;
use Sylius\Component\Translation\Factory\TranslatableFactory;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
@ -72,73 +64,6 @@ class Configuration implements ConfigurationInterface
->arrayNode('resources')
->addDefaultsIfNotSet()
->children()
->arrayNode('taxonomy')
->addDefaultsIfNotSet()
->children()
->variableNode('options')->end()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(Taxonomy::class)->cannotBeEmpty()->end()
->scalarNode('interface')->defaultValue(TaxonomyInterface::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(TaxonomyFactory::class)->end()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('default')->defaultValue(TaxonomyType::class)->cannotBeEmpty()->end()
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->arrayNode('validation_groups')
->addDefaultsIfNotSet()
->children()
->arrayNode('default')
->prototype('scalar')->end()
->defaultValue(['sylius'])
->end()
->end()
->end()
->arrayNode('translation')
->addDefaultsIfNotSet()
->children()
->variableNode('options')->end()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(TaxonomyTranslation::class)->cannotBeEmpty()->end()
->scalarNode('interface')->defaultValue(TaxonomyTranslationInterface::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(Factory::class)->end()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('default')->defaultValue(TaxonomyTranslationType::class)->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->arrayNode('validation_groups')
->addDefaultsIfNotSet()
->children()
->arrayNode('default')
->prototype('scalar')->end()
->defaultValue(['sylius'])
->end()
->end()
->end()
->arrayNode('fields')
->prototype('scalar')->end()
->defaultValue(['name'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('taxon')
->addDefaultsIfNotSet()
->children()
@ -150,7 +75,7 @@ class Configuration implements ConfigurationInterface
->scalarNode('interface')->defaultValue(TaxonInterface::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(TaxonFactory::class)->end()
->scalarNode('factory')->defaultValue(TranslatableFactory::class)->end()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()

View file

@ -12,14 +12,9 @@
namespace Sylius\Bundle\TaxonomyBundle\DependencyInjection;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Sylius\Component\Resource\Factory\Factory;
use Sylius\Component\Translation\Factory\TranslatableFactory;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
@ -45,43 +40,5 @@ class SyliusTaxonomyExtension extends AbstractResourceExtension
foreach ($configFiles as $configFile) {
$loader->load($configFile);
}
$factoryDefinition = new Definition(Factory::class);
$factoryDefinition->setArguments(
[
new Parameter('sylius.model.taxonomy.class'),
]
);
$translatableFactoryDefinition = $container->getDefinition('sylius.factory.taxonomy');
$taxonomyFactoryClass = $translatableFactoryDefinition->getClass();
$translatableFactoryDefinition->setClass(TranslatableFactory::class);
$translatableFactoryDefinition->setArguments(
[
$factoryDefinition,
new Reference('sylius.translation.locale_provider'),
]
);
$decoratedTaxonomyFactoryDefinition = new Definition($taxonomyFactoryClass);
$decoratedTaxonomyFactoryDefinition->setArguments(
[
$translatableFactoryDefinition,
new Reference('sylius.factory.taxon'),
]
);
$container->setDefinition('sylius.factory.taxonomy', $decoratedTaxonomyFactoryDefinition);
$taxonFactoryDefinition = $container->getDefinition('sylius.factory.taxon');
$taxonFactoryClass = $taxonFactoryDefinition->getClass();
$taxonFactoryDefinition->setClass(TranslatableFactory::class);
$decoratedTaxonFactoryDefinition = new Definition($taxonFactoryClass);
$decoratedTaxonFactoryDefinition
->addArgument($taxonFactoryDefinition)
->addArgument(new Reference('sylius.repository.taxonomy'))
;
$container->setDefinition('sylius.factory.taxon', $decoratedTaxonFactoryDefinition);
}
}

View file

@ -12,46 +12,58 @@
namespace Sylius\Bundle\TaxonomyBundle\Doctrine\ORM;
use Sylius\Bundle\TranslationBundle\Doctrine\ORM\TranslatableResourceRepository;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
/**
* @author Saša Stamenković <umpirsky@gmail.com>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
* @author Anna Walasek <anna.walasek@lakion.com>
* @author Aram Alipoor <aram.alipoor@gmail.com>
*/
class TaxonRepository extends TranslatableResourceRepository implements TaxonRepositoryInterface
{
public function getTaxonsAsList(TaxonomyInterface $taxonomy)
/**
* @param TaxonInterface $taxon
*
* @return array
*/
public function findChildren(TaxonInterface $taxon)
{
return $this->getQueryBuilder()
->where('o.taxonomy = :taxonomy')
->andWhere('o.parent IS NOT NULL')
->setParameter('taxonomy', $taxonomy)
->orderBy('o.left')
->getQuery()
->getResult();
$queryBuilder = $this->getQueryBuilder();
$queryBuilder
->andWhere($queryBuilder->expr()->gt('o.left', ':left'))
->andWhere($queryBuilder->expr()->lt('o.right', ':right'))
->setParameter('left', $taxon->getLeft())
->setParameter('right', $taxon->getRight())
;
return $queryBuilder->getQuery()->getResult();
}
/**
* @param string $permalink
* @return TaxonInterface
*
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneByPermalink($permalink)
{
return $this->getQueryBuilder()
->where('translation.permalink = :permalink')
->setParameter('permalink', $permalink)
->orderBy($this->getAlias().'.left')
->orderBy('o.left')
->getQuery()
->getOneOrNullResult();
}
/**
* {@inheritdoc}
* @return array
*/
public function getNonRootTaxons()
public function findRootNodes()
{
return $this->getQueryBuilder()
->where($this->getAlias().'.parent IS NOT NULL')
->orderBy($this->getAlias().'.left')
->getQuery()
->getResult();
$queryBuilder = $this->getQueryBuilder();
$queryBuilder
->andWhere($queryBuilder->expr()->isNull($this->getPropertyName('parent')))
;
return $queryBuilder->getQuery()->getResult();
}
}
}

View file

@ -1,55 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Doctrine\ORM;
use Sylius\Bundle\TranslationBundle\Doctrine\ORM\TranslatableResourceRepository;
/**
* Base taxonomy repository.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class TaxonomyRepository extends TranslatableResourceRepository
{
/**
* {@inheritdoc}
*/
protected function getQueryBuilder()
{
return parent::getQueryBuilder()
->select('taxonomy, root, taxons')
->leftJoin('taxonomy.root', 'root')
->leftJoin('root.children', 'taxons')
;
}
/**
* {@inheritdoc}
*/
protected function getCollectionQueryBuilder()
{
return parent::getQueryBuilder()
->select('taxonomy, root, taxons')
->leftJoin('taxonomy.root', 'root')
->leftJoin('root.children', 'taxons')
;
}
/**
* {@inheritdoc}
*/
protected function getAlias()
{
return 'taxonomy';
}
}

View file

@ -1,91 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Form\DataTransformer;
use Doctrine\Common\Collections\Collection;
use Sylius\Bundle\ResourceBundle\Form\DataTransformer\ObjectSelectionToIdentifierCollectionTransformer;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
/**
* Transforms arrays of selected taxons into one collection.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Patrick Berenschot <p.berenschot@taka-a-byte.eu>
*/
class TaxonSelectionToCollectionTransformer extends ObjectSelectionToIdentifierCollectionTransformer
{
/**
* {@inheritdoc}
*/
public function transform($value)
{
$taxons = [];
foreach ($this->objects as $taxonomy) {
$taxons[$taxonomy->getId()] = [];
}
if (null === $value) {
return $taxons;
}
if (!$value instanceof Collection) {
throw new UnexpectedTypeException($value, Collection::class);
}
return $this->processObjects($value, $taxons);
}
private function processObjects(Collection $value, array $taxons)
{
/* @var $taxonomy TaxonomyInterface */
foreach ($this->objects as $taxonomy) {
/* @var $taxon TaxonInterface */
foreach ($taxonomy->getTaxons() as $taxon) {
$this->addChildren($taxonomy, $value, $taxon->getChildren(), $taxons);
if ($value->contains($this->saveObjects ? $taxon : $taxon->getId())) {
$taxons[$taxonomy->getId()][] = $taxon;
}
}
}
return $taxons;
}
/**
* Add taxon childs to the taxons array recursively.
*
* @param TaxonomyInterface $taxonomy
* @param Collection $value
* @param \Traversable $children
* @param array $taxons
*/
private function addChildren(TaxonomyInterface $taxonomy, Collection $value, $children, array &$taxons)
{
if (!is_array($children) && !$children instanceof \Traversable) {
throw new \InvalidArgumentException('Expecting array or Traversable!');
}
/* @var $children TaxonInterface[] */
foreach ($children as $child) {
if ($value->contains($this->saveObjects ? $child : $child->getId())) {
$taxons[$taxonomy->getId()][] = $child;
}
if (!$child->getChildren()->isEmpty()) {
$this->addChildren($taxonomy, $value, $child->getChildren(), $taxons);
}
}
}
}

View file

@ -1,65 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Form\DataTransformer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
class TaxonSelectionToIdentifierCollectionTransformer implements DataTransformerInterface
{
/**
* {@inheritdoc}
*/
public function transform($value)
{
if (null === $value) {
return [];
}
if (!$value instanceof Collection) {
throw new UnexpectedTypeException($value, Collection::class);
}
return $value->toArray();
}
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (empty($value)) {
return new ArrayCollection();
}
if (!is_array($value) && !$value instanceof \Traversable && !$value instanceof \ArrayAccess) {
throw new UnexpectedTypeException($value, '\Traversable or \ArrayAccess');
}
return $this->createCollection($value);
}
private function createCollection($value)
{
$taxons = new ArrayCollection();
foreach ($value as $taxonomy) {
foreach ($taxonomy as $taxon) {
$taxons->add($taxon->getId());
}
}
return $taxons;
}
}

View file

@ -18,7 +18,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormFactoryInterface;
/**
* Adds the parent taxon field choice based on the selected taxonomy.
* Adds the parent taxon field choice.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
@ -48,7 +48,6 @@ class BuildTaxonFormSubscriber implements EventSubscriberInterface
{
return [
FormEvents::PRE_SET_DATA => 'preSetData',
FormEvents::POST_SUBMIT => 'postSubmit',
];
}
@ -66,7 +65,6 @@ class BuildTaxonFormSubscriber implements EventSubscriberInterface
}
$event->getForm()->add($this->factory->createNamed('parent', 'sylius_taxon_choice', $taxon->getParent(), [
'taxonomy' => $taxon->getTaxonomy(),
'filter' => $this->getFilterTaxonOption($taxon),
'required' => false,
'label' => 'sylius.form.taxon.parent',
@ -75,22 +73,6 @@ class BuildTaxonFormSubscriber implements EventSubscriberInterface
]));
}
/**
* Reset the taxon root if it's null.
*
* @param FormEvent $event
*/
public function postSubmit(FormEvent $event)
{
$taxon = $event->getData();
$taxonomy = $taxon->getTaxonomy();
if (null === $taxon->getParent()) {
$taxon->setParent($taxonomy->getRoot());
}
}
/**
* Get the closure to filter taxon collection.
*

View file

@ -11,12 +11,15 @@
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -50,6 +53,46 @@ class TaxonChoiceType extends AbstractType
}
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
/** @var ChoiceView $choice */
foreach ($view->vars['choices'] as $choice) {
$choice->label = str_repeat('— ' , $choice->data->getLevel()).$choice->label;
}
}
/**
* {@inheritdoc}
*/
protected function buildTreeChoices($choices , $level = 0)
{
$result = array();
/** @var TaxonInterface $choice */
foreach ($choices as $choice) {
$result[] = new ChoiceView(
str_repeat('-' , $level).' '.$choice->getName(),
$choice->getId(),
$choice,
[]
);
if (!$choice->getChildren()->isEmpty()) {
$result = array_merge(
$result,
$this->buildTreeChoices($choice->getChildren(), $level + 1)
);
}
}
return $result;
}
/**
* {@inheritdoc}
*/
@ -65,26 +108,27 @@ class TaxonChoiceType extends AbstractType
{
$repository = $this->taxonRepository;
$choiceList = function (Options $options) use ($repository) {
$taxons = $repository->getNonRootTaxons();
if (null !== $options['taxonomy']) {
$taxons = $repository->getTaxonsAsList($options['taxonomy']);
/** @var TaxonRepositoryInterface $repository */
if (null !== $options['root']) {
$taxons = $repository->findChildren($options['root']);
} else {
$taxons = $repository->findAll();
}
if (null !== $options['filter']) {
$taxons = array_filter($taxons, $options['filter']);
}
return new ObjectChoiceList($taxons, null, [], 'taxonomy', 'id');
return new ObjectChoiceList($taxons, null, [], null, 'id');
};
$resolver
->setDefaults([
'choice_list' => $choiceList,
'taxonomy' => null,
'root' => null,
'filter' => null,
])
->setAllowedTypes('taxonomy', [TaxonomyInterface::class, 'null'])
->setAllowedTypes('root', [TaxonInterface::class, 'null'])
->setAllowedTypes('filter', ['callable', 'null'])
;
}

View file

@ -1,119 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
use Sylius\Bundle\TaxonomyBundle\Form\DataTransformer\TaxonSelectionToCollectionTransformer;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Taxon selection form.
* It creates one select form for each taxonomy.
* Transforms it into collection of taxons.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Saša Stamenković <umpirsky@gmail.com>
*/
class TaxonSelectionType extends AbstractType
{
/**
* Taxonomies repository.
*
* @var RepositoryInterface
*/
protected $taxonomyRepository;
/**
* Taxonon repository.
*
* @var TaxonRepositoryInterface
*/
protected $taxonRepository;
/**
* Constructor.
*
* @param RepositoryInterface $taxonomyRepository
* @param TaxonRepositoryInterface $taxonRepository
*/
public function __construct(RepositoryInterface $taxonomyRepository, TaxonRepositoryInterface $taxonRepository)
{
$this->taxonomyRepository = $taxonomyRepository;
$this->taxonRepository = $taxonRepository;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$taxonomies = $this->taxonomyRepository->findAll();
$builder->addModelTransformer(new $options['model_transformer']['class']($taxonomies, $options['model_transformer']['save_objects']));
foreach ($taxonomies as $taxonomy) {
/* @var $taxonomy TaxonomyInterface */
$builder->add($taxonomy->getId(), 'choice', [
'choice_list' => new ObjectChoiceList($this->taxonRepository->getTaxonsAsList($taxonomy), null, [], null, 'id'),
'multiple' => $options['multiple'],
'label' => /* @Ignore */ $taxonomy->getName(),
]);
}
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'data_class' => null,
'multiple' => true,
'render_label' => false,
'model_transformer' => TaxonSelectionToCollectionTransformer::class,
])
;
$resolver->setNormalizer('model_transformer', function (Options $options, $value) {
if (!is_array($value)) {
$value = [
'class' => $value,
'save_objects' => true,
];
} else {
if (!isset($value['class'])) {
$value['class'] = TaxonSelectionToCollectionTransformer::class;
}
if (!isset($value['save_objects'])) {
$value['save_objects'] = true;
}
}
return $value;
});
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_taxon_selection';
}
}

View file

@ -1,43 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Taxonomy translation form type.
*
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class TaxonomyTranslationType extends AbstractResourceType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text', [
'label' => 'sylius.form.taxonomy.name',
])
;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_taxonomy_translation';
}
}

View file

@ -1,47 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Taxonomy form form.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class TaxonomyType extends AbstractResourceType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('translations', 'a2lix_translationsForms', [
'form_type' => 'sylius_taxonomy_translation',
'label' => 'sylius.form.taxonomy.name',
])
->addEventSubscriber(new AddCodeFormSubscriber())
;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_taxonomy';
}
}

View file

@ -22,10 +22,6 @@
<generator strategy="AUTO" />
</id>
<many-to-one field="taxonomy" target-entity="Sylius\Component\Taxonomy\Model\TaxonomyInterface">
<join-column name="taxonomy_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
</many-to-one>
<many-to-one field="parent" target-entity="Sylius\Component\Taxonomy\Model\TaxonInterface" inversed-by="children">
<join-column name="parent_id" referenced-column-name="id" nullable="true" on-delete="CASCADE" />
<gedmo:tree-parent />
@ -44,7 +40,7 @@
<order-by-field name="left" direction="ASC" />
</order-by>
<field name="code" column="code" type="string" unique="true"/>
<field name="code" column="code" type="string" unique="true" />
<field name="left" column="tree_left" type="integer">
<gedmo:tree-left />
</field>

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
<mapped-superclass name="Sylius\Bundle\TaxonomyBundle\Document\Taxonomy" collection="sylius_taxonomy">
<field name="name" column="name" type="string" />
</mapped-superclass>
</doctrine-mongo-mapping>

View file

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Taxonomy\Model\Taxonomy">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<many-to-one field="root" target-entity="Sylius\Component\Taxonomy\Model\TaxonInterface">
<join-column name="root_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
<cascade>
<cascade-all/>
</cascade>
</many-to-one>
</mapped-superclass>
</doctrine-mapping>

View file

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Taxonomy\Model\TaxonomyTranslation" table="sylius_taxonomy_translation">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" column="name" type="string" />
</mapped-superclass>
</doctrine-mapping>

View file

@ -17,20 +17,10 @@
http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sylius.repository.taxonomy.class">Sylius\Bundle\ResourceBundle\Doctrine\ODM\MongoDB\DocumentRepository</parameter>
<parameter key="sylius.repository.taxon.class">Sylius\Bundle\ResourceBundle\Doctrine\ODM\MongoDB\DocumentRepository</parameter>
</parameters>
<services>
<service id="sylius.manager.taxonomy" alias="doctrine.odm.mongodb.document_manager" />
<service id="sylius.doctrine.odm.mongodb.metadata.taxonomy"
factory-service="sylius.manager.taxonomy"
factory-method="getClassMetadata"
class="Doctrine\ODM\MongoDB\Mapping\ClassMetadata"
public="false"
>
<argument>%sylius.model.taxonomy.class%</argument>
</service>
<service id="sylius.doctrine.odm.mongodb.unitOfWork"
factory-service="doctrine.odm.mongodb.document_manager"
factory-method="getUnitOfWork"
@ -39,12 +29,6 @@
>
</service>
<service id="sylius.repository.taxonomy" class="%sylius.repository.taxonomy.class%">
<argument type="service" id="sylius.manager.taxonomy" />
<argument type="service" id="sylius.doctrine.odm.mongodb.unitOfWork" />
<argument type="service" id="sylius.doctrine.odm.mongodb.metadata.taxonomy" />
</service>
<service id="sylius.manager.taxon" alias="doctrine.odm.mongodb.document_manager" />
<service id="sylius.doctrine.odm.mongodb.metadata.taxon"
factory-service="sylius.manager.taxon"

View file

@ -17,7 +17,6 @@
http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sylius.repository.taxonomy.class">Sylius\Bundle\TaxonomyBundle\Doctrine\ORM\TaxonomyRepository</parameter>
<parameter key="sylius.repository.taxon.class">Sylius\Bundle\TaxonomyBundle\Doctrine\ORM\TaxonRepository</parameter>
</parameters>

View file

@ -1,7 +1,3 @@
sylius_taxonomy:
resource: @SyliusTaxonomyBundle/Resources/config/routing/taxonomy.yml
prefix: /taxonomy
sylius_taxon:
resource: @SyliusTaxonomyBundle/Resources/config/routing/taxon.yml
prefix: /taxonomy/{taxonomyId}/taxon
prefix: /taxon

View file

@ -3,27 +3,15 @@ sylius_taxon_create:
methods: [GET, POST]
defaults:
_controller: sylius.controller.taxon:createAction
_sylius:
redirect:
route: sylius_taxonomy_show
parameters: {'id': $taxonomyId}
sylius_taxon_update:
path: /{id}/edit
methods: [GET, POST]
defaults:
_controller: sylius.controller.taxon:updateAction
_sylius:
redirect:
route: sylius_taxonomy_show
parameters: {'id': $taxonomyId}
sylius_taxon_delete:
path: /{id}
methods: [POST]
defaults:
_controller: sylius.controller.taxon:deleteAction
_sylius:
redirect:
route: sylius_taxonomy_show
parameters: {'id': $taxonomyId}

View file

@ -1,32 +0,0 @@
sylius_taxonomy_index:
path: /
methods: [GET]
defaults:
_controller: sylius.controller.taxonomy:indexAction
_sylius:
sortable: true
paginate: 50
sylius_taxonomy_create:
path: /new
methods: [GET, POST]
defaults:
_controller: sylius.controller.taxonomy:createAction
sylius_taxonomy_update:
path: /{id}/edit
methods: [GET, POST]
defaults:
_controller: sylius.controller.taxonomy:updateAction
sylius_taxonomy_delete:
path: /{id}
methods: [POST]
defaults:
_controller: sylius.controller.taxonomy:deleteAction
sylius_taxonomy_show:
path: /{id}
methods: [GET]
defaults:
_controller: sylius.controller.taxonomy:showAction

View file

@ -1,19 +0,0 @@
Sylius\Component\Taxonomy\Model\Taxonomy:
exclusion_policy: ALL
xml_root_name: taxonomy
properties:
id:
expose: true
type: integer
xml_attribute: true
name:
expose: true
type: string
root:
expose: true
relations:
- rel: self
href:
route: sylius_api_taxonomy_show
parameters:
id: expr(object.getId())

View file

@ -18,7 +18,6 @@
<parameters>
<parameter key="sylius.form.type.taxon_choice.class">Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonChoiceType</parameter>
<parameter key="sylius.form.type.taxon_selection.class">Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonSelectionType</parameter>
</parameters>
<services>
@ -26,12 +25,6 @@
<argument type="service" id="sylius.repository.taxon" />
<tag name="form.type" alias="sylius_taxon_choice" />
</service>
<service id="sylius.form.type.taxon_selection" class="%sylius.form.type.taxon_selection.class%">
<argument type="service" id="sylius.repository.taxonomy" />
<argument type="service" id="sylius.repository.taxon" />
<tag name="form.type" alias="sylius_taxon_selection" />
</service>
</services>
</container>

View file

@ -16,26 +16,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Sylius\Component\Taxonomy\Model\Taxonomy">
<property name="translations">
<constraint name="Valid" />
</property>
</class>
<class name="Sylius\Component\Taxonomy\Model\TaxonomyTranslation">
<getter property="name">
<constraint name="NotBlank">
<option name="message">sylius.taxonomy.name.not_blank</option>
<option name="groups">sylius</option>
</constraint>
<constraint name="Length">
<option name="max">255</option>
<option name="maxMessage">sylius.taxonomy.name.max_length</option>
<option name="groups">sylius</option>
</constraint>
</getter>
</class>
<class name="Sylius\Component\Taxonomy\Model\Taxon">
<property name="translations">
<constraint name="Valid" />

View file

@ -14,7 +14,6 @@ namespace Sylius\Bundle\TaxonomyBundle;
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
/**
* Flexible categorization system.
@ -41,7 +40,6 @@ class SyliusTaxonomyBundle extends AbstractResourceBundle
protected function getModelInterfaces()
{
return [
TaxonomyInterface::class => 'sylius.model.taxonomy.class',
TaxonInterface::class => 'sylius.model.taxon.class',
];
}

View file

@ -1,111 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Doctrine\ORM;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\QueryBuilder;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
class TaxonRepositorySpec extends ObjectBehavior
{
function let(EntityManager $em, ClassMetadata $classMetadata)
{
$this->beConstructedWith($em, $classMetadata);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\TaxonomyBundle\Doctrine\ORM\TaxonRepository');
}
function it_finds_taxon_as_a_list($em, TaxonomyInterface $taxonomy, QueryBuilder $builder, AbstractQuery $query)
{
$em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
$builder->select('o')->shouldBeCalled()->willReturn($builder);
$builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder);
$builder->addSelect('translation')->shouldBeCalled()->willReturn($builder);
$builder->leftJoin('o.translations', 'translation')->shouldBeCalled()->willReturn($builder);
$builder->where('o.taxonomy = :taxonomy')->shouldBeCalled()->willReturn($builder);
$builder->andWhere('o.parent IS NOT NULL')->shouldBeCalled()->willReturn($builder);
$builder->setParameter('taxonomy', $taxonomy)->shouldBeCalled()->willReturn($builder);
$builder->orderBy('o.left')->shouldBeCalled()->willReturn($builder);
$builder->getQuery()->shouldBeCalled()->willReturn($query);
$query->getResult()->shouldBeCalled();
$this->getTaxonsAsList($taxonomy);
}
function it_finds_one_taxon_by_permalink($em, QueryBuilder $builder, AbstractQuery $query)
{
$em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
$builder->select('o')->shouldBeCalled()->willReturn($builder);
$builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder);
$builder->addSelect('translation')->shouldBeCalled()->willReturn($builder);
$builder->leftJoin('o.translations', 'translation')->shouldBeCalled()->willReturn($builder);
$builder->where('translation.permalink = :permalink')->shouldBeCalled()->willReturn($builder);
$builder->setParameter('permalink', 'link')->shouldBeCalled()->willReturn($builder);
$builder->orderBy('o.left')->shouldBeCalled()->willReturn($builder);
$builder->getQuery()->shouldBeCalled()->willReturn($query);
$query->getOneOrNullResult()->shouldBeCalled();
$this->findOneByPermalink('link');
}
function it_finds_non_root_taxons($em, QueryBuilder $builder, AbstractQuery $query)
{
$em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
$builder
->select('o')
->shouldBeCalled()
->willReturn($builder)
;
$builder
->from(Argument::any(), 'o', Argument::cetera())
->shouldBeCalled()
->willReturn($builder)
;
$builder
->addSelect('translation')
->shouldBeCalled()
->willReturn($builder)
;
$builder
->leftJoin('o.translations', 'translation')
->shouldBeCalled()
->willReturn($builder)
;
$builder
->where('o.parent IS NOT NULL')
->shouldBeCalled()
->willReturn($builder)
;
$builder
->orderBy('o.left')
->shouldBeCalled()
->willReturn($builder)
;
$builder
->getQuery()
->shouldBeCalled()
->willReturn($query)
;
$query->getResult()->shouldBeCalled();
$this->getNonRootTaxons();
}
}

View file

@ -1,37 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Form\DataTransformer;
class FakeEntity
{
protected $id;
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function getTaxons()
{
return [];
}
public function getChildren()
{
return [];
}
}

View file

@ -1,92 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Form\DataTransformer;
use Doctrine\Common\Collections\Collection;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
class TaxonSelectionToCollectionTransformerSpec extends ObjectBehavior
{
function let(TaxonomyInterface $entityOne, TaxonomyInterface $entityTwo)
{
$entityOne->getId()->willReturn(1);
$entityTwo->getId()->willReturn(2);
$this->beConstructedWith([$entityOne, $entityTwo]);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\TaxonomyBundle\Form\DataTransformer\TaxonSelectionToCollectionTransformer');
}
function it_does_transform_null_value()
{
$this->transform(null)->shouldReturn([1 => [], 2 => []]);
}
function it_does_not_transform_string_value()
{
$this->shouldThrow(UnexpectedTypeException::class)->duringTransform('');
}
function it_does_transform_collection_with_objects_value(
$entityOne,
$entityTwo,
TaxonInterface $entityThree,
TaxonInterface $entityFour,
Collection $collection
) {
$entityThree->getId()->willReturn(3);
$entityFour->getId()->willReturn(4);
$entityOne->getTaxons()->willReturn([$entityThree]);
$entityTwo->getTaxons()->willReturn([$entityFour]);
$entityThree->getChildren()->willReturn([]);
$entityFour->getChildren()->willReturn([]);
$collection->contains($entityThree)->willReturn(true);
$collection->contains($entityFour)->willReturn(true);
$this->transform($collection)->shouldReturn([1 => [$entityThree], 2 => [$entityFour]]);
}
function it_does_reverse_transform_empty_value()
{
$this->reverseTransform('')->shouldImplement(Collection::class);
}
function it_does_not_reverse_transform_string_value()
{
$this->shouldThrow(UnexpectedTypeException::class)
->duringReverseTransform('string');
}
function it_does_reverse_transform_array_value(TaxonInterface $entity)
{
$entity->getId()->willReturn(1);
$this->reverseTransform([$entity])->shouldHaveCount(1);
}
function it_does_reverse_transform_array_of_arrays_value(TaxonInterface $entityThree, TaxonInterface $entityFour)
{
$entityThree->getId()->willReturn(3);
$entityFour->getId()->willReturn(4);
$this->reverseTransform([[$entityThree, $entityFour]])->shouldHaveCount(2);
}
}

View file

@ -13,7 +13,6 @@ namespace spec\Sylius\Bundle\TaxonomyBundle\Form\EventListener;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@ -41,7 +40,6 @@ class BuildTaxonFormSubscriberSpec extends ObjectBehavior
{
$this::getSubscribedEvents()->shouldReturn([
FormEvents::PRE_SET_DATA => 'preSetData',
FormEvents::POST_SUBMIT => 'postSubmit',
]);
}
@ -51,18 +49,15 @@ class BuildTaxonFormSubscriberSpec extends ObjectBehavior
FormInterface $form,
TaxonInterface $taxon,
TaxonInterface $parent,
FormInterface $parentForm,
TaxonomyInterface $taxonomy
FormInterface $parentForm
) {
$event->getForm()->shouldBeCalled()->willReturn($form);
$event->getData()->shouldBeCalled()->willReturn($taxon);
$taxon->getId()->shouldBeCalled()->willReturn(null);
$taxon->getTaxonomy()->shouldBeCalled()->willReturn($taxonomy);
$taxon->getParent()->shouldBeCalled()->willReturn($parent);
$factory->createNamed('parent', 'sylius_taxon_choice', $parent, [
'taxonomy' => $taxonomy,
'filter' => null,
'required' => false,
'label' => 'sylius.form.taxon.parent',
@ -74,20 +69,4 @@ class BuildTaxonFormSubscriberSpec extends ObjectBehavior
$this->preSetData($event);
}
function it_sets_parent_to_the_taxon(
FormEvent $event,
TaxonInterface $taxon,
TaxonomyInterface $taxonomy,
TaxonInterface $root
) {
$event->getData()->shouldBeCalled()->willReturn($taxon);
$taxon->getTaxonomy()->shouldBeCalled()->willReturn($taxonomy);
$taxon->getParent()->shouldBeCalled()->willReturn(null);
$taxonomy->getRoot()->shouldBeCalled()->willReturn($root);
$taxon->setParent($root)->shouldBeCalled();
$this->postSubmit($event);
}
}

View file

@ -13,10 +13,8 @@ namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Taxonomy\Model\TaxonomyInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -37,24 +35,13 @@ class TaxonChoiceTypeSpec extends ObjectBehavior
$this->shouldImplement(FormTypeInterface::class);
}
function it_builds_a_form(FormBuilderInterface $builder)
{
$builder->addModelTransformer(
Argument::type(CollectionToArrayTransformer::class)
)->shouldBeCalled();
$this->buildForm($builder, [
'multiple' => true,
]);
}
function it_has_options(OptionsResolver $resolver)
{
$resolver->setDefaults(Argument::withKey('choice_list'))->shouldBeCalled()->willReturn($resolver);
$resolver->setDefaults(Argument::withKey('taxonomy'))->shouldBeCalled()->willReturn($resolver);
$resolver->setDefaults(Argument::withKey('root'))->shouldBeCalled()->willReturn($resolver);
$resolver->setDefaults(Argument::withKey('filter'))->shouldBeCalled()->willReturn($resolver);
$resolver->setAllowedTypes('taxonomy', [TaxonomyInterface::class, 'null'])->shouldBeCalled()->willReturn($resolver);
$resolver->setAllowedTypes('root', [TaxonInterface::class, 'null'])->shouldBeCalled()->willReturn($resolver);
$resolver->setAllowedTypes('filter', ['callable', 'null'])->shouldBeCalled()->willReturn($resolver);
$this->configureOptions($resolver, []);

View file

@ -1,96 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\TaxonomyBundle\Form\DataTransformer\TaxonSelectionToCollectionTransformer;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Taxonomy\Model\Taxon;
use Sylius\Component\Taxonomy\Model\Taxonomy;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TaxonSelectionTypeSpec extends ObjectBehavior
{
function let(RepositoryInterface $taxonomyRepository, TaxonRepositoryInterface $taxonRepository)
{
$this->beConstructedWith($taxonomyRepository, $taxonRepository);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonSelectionType');
}
function it_is_a_form_type()
{
$this->shouldImplement(FormTypeInterface::class);
}
function it_builds_a_form(
$taxonomyRepository,
$taxonRepository,
FormBuilderInterface $builder,
DataTransformerInterface $dataTransformer,
Taxonomy $taxonomy,
Taxon $taxon
) {
$taxonomyRepository->findAll()->shouldBeCalled()->willReturn([$taxonomy]);
$taxonRepository->getTaxonsAsList($taxonomy)->shouldBeCalled()->willReturn([$taxon]);
$taxonomy->getId()->shouldBeCalled()->willreturn(12);
$taxonomy->getName()->shouldBeCalled()->willReturn('taxonomy name');
$taxon->getId()->shouldBeCalled();
$taxon->__toString()->shouldBeCalled()->willReturn('taxon name');
$builder->addModelTransformer(Argument::any())->shouldBeCalled();
$builder->add(12, 'choice', Argument::withKey('choice_list'))->shouldBeCalled();
$this->buildForm($builder, [
'model_transformer' => [
'class' => $dataTransformer,
'save_objects' => false,
],
'multiple' => true,
]);
}
function it_is_a_form()
{
$this->shouldHaveType(AbstractType::class);
}
function it_has_options(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => null,
'multiple' => true,
'render_label' => false,
'model_transformer' => TaxonSelectionToCollectionTransformer::class,
])->shouldBeCalled();
$resolver->setNormalizer('model_transformer', Argument::type('callable'))->shouldBeCalled();
$this->configureOptions($resolver);
}
function it_has_a_name()
{
$this->getName()->shouldReturn('sylius_taxon_selection');
}
}

View file

@ -1,62 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class TaxonomyTranslationTypeSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('TaxonomyTranslation', ['sylius']);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyTranslationType');
}
function it_is_a_form_type()
{
$this->shouldImplement(FormTypeInterface::class);
}
function it_builds_form_with_proper_fields(FormBuilder $builder)
{
$builder
->add('name', 'text', Argument::any())
->willReturn($builder)
;
$this->buildForm($builder, []);
}
function it_defines_data_class(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'data_class' => 'TaxonomyTranslation',
'validation_groups' => ['sylius'],
])
->shouldBeCalled()
;
$this->configureOptions($resolver);
}
}

View file

@ -1,70 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\TaxonomyBundle\Form\Type;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
*/
class TaxonomyTypeSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('Taxonomy', ['sylius']);
}
function it_is_initializable()
{
$this->shouldHaveType('Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonomyType');
}
function it_is_a_form_type()
{
$this->shouldImplement(FormTypeInterface::class);
}
function it_builds_form_with_proper_fields(FormBuilder $builder)
{
$builder
->add('translations', 'a2lix_translationsForms', Argument::any())
->shouldBeCalled()
->willReturn($builder)
;
$builder
->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))
->shouldBeCalled()
->willReturn($builder);
$this->buildForm($builder, []);
}
function it_defines_data_class(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'data_class' => 'Taxonomy',
'validation_groups' => ['sylius'],
])
->shouldBeCalled()
;
$this->configureOptions($resolver);
}
}

View file

@ -26,7 +26,7 @@ class MenuBuilderEvent extends Event
const BACKEND_SIDEBAR = 'sylius.menu_builder.backend.sidebar';
const FRONTEND_MAIN = 'sylius.menu_builder.frontend.main';
const FRONTEND_CURRENCY = 'sylius.menu_builder.frontend.currency';
const FRONTEND_TAXONOMIES = 'sylius.menu_builder.frontend.taxonomies';
const FRONTEND_TAXONS = 'sylius.menu_builder.frontend.taxons';
const FRONTEND_SOCIAL = 'sylius.menu_builder.frontend.social';
const FRONTEND_ACCOUNT = 'sylius.menu_builder.frontend.account';

View file

@ -115,11 +115,11 @@ class BackendMenuBuilder extends MenuBuilder
->setLabel($this->translate(sprintf('sylius.backend.menu.%s.assortment', $section)))
;
if ($this->rbacAuthorizationChecker->isGranted('sylius.taxonomy.index')) {
$child->addChild('taxonomies', [
'route' => 'sylius_backend_taxonomy_index',
if ($this->rbacAuthorizationChecker->isGranted('sylius.taxon.index')) {
$child->addChild('taxons', [
'route' => 'sylius_backend_taxon_index',
'labelAttributes' => ['icon' => 'glyphicon glyphicon-folder-close'],
])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.taxonomies', $section)));
])->setLabel($this->translate(sprintf('sylius.backend.menu.%s.taxons', $section)));
}
if ($this->rbacAuthorizationChecker->isGranted('sylius.product.index')) {

View file

@ -19,8 +19,8 @@ use Sylius\Component\Cart\Provider\CartProviderInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Currency\Provider\CurrencyProviderInterface;
use Sylius\Component\Rbac\Authorization\AuthorizationCheckerInterface as RbacAuthorizationCheckerInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@ -42,11 +42,11 @@ class FrontendMenuBuilder extends MenuBuilder
protected $currencyProvider;
/**
* Taxonomy repository.
* Taxon repository.
*
* @var RepositoryInterface
* @var TaxonRepositoryInterface
*/
protected $taxonomyRepository;
protected $taxonRepository;
/**
* Cart provider.
@ -73,15 +73,13 @@ class FrontendMenuBuilder extends MenuBuilder
protected $tokenStorage;
/**
* Constructor.
*
* @param FactoryInterface $factory
* @param AuthorizationCheckerInterface $authorizationChecker
* @param TranslatorInterface $translator
* @param EventDispatcherInterface $eventDispatcher
* @param RbacAuthorizationCheckerInterface $rbacAuthorizationChecker
* @param CurrencyProviderInterface $currencyProvider
* @param RepositoryInterface $taxonomyRepository
* @param TaxonRepositoryInterface $taxonRepository
* @param CartProviderInterface $cartProvider
* @param CurrencyHelper $currencyHelper
* @param ChannelContextInterface $channelContext
@ -94,7 +92,7 @@ class FrontendMenuBuilder extends MenuBuilder
EventDispatcherInterface $eventDispatcher,
RbacAuthorizationCheckerInterface $rbacAuthorizationChecker,
CurrencyProviderInterface $currencyProvider,
RepositoryInterface $taxonomyRepository,
TaxonRepositoryInterface $taxonRepository,
CartProviderInterface $cartProvider,
CurrencyHelper $currencyHelper,
ChannelContextInterface $channelContext,
@ -103,7 +101,7 @@ class FrontendMenuBuilder extends MenuBuilder
parent::__construct($factory, $authorizationChecker, $translator, $eventDispatcher, $rbacAuthorizationChecker);
$this->currencyProvider = $currencyProvider;
$this->taxonomyRepository = $taxonomyRepository;
$this->taxonRepository = $taxonRepository;
$this->cartProvider = $cartProvider;
$this->currencyHelper = $currencyHelper;
$this->channelContext = $channelContext;
@ -239,11 +237,11 @@ class FrontendMenuBuilder extends MenuBuilder
}
/**
* Builds frontend taxonomies menu.
* Builds frontend taxons menu.
*
* @return ItemInterface
*/
public function createTaxonomiesMenu()
public function createTaxonsMenu()
{
$menu = $this->factory->createItem('root', [
'childrenAttributes' => [
@ -257,19 +255,19 @@ class FrontendMenuBuilder extends MenuBuilder
'labelAttributes' => ['class' => 'nav-header'],
];
$taxonomies = $this->channelContext->getChannel()->getTaxonomies();
$taxons = $this->channelContext->getChannel()->getTaxons();
foreach ($taxonomies as $taxonomy) {
$child = $menu->addChild($taxonomy->getName(), $childOptions);
foreach ($taxons as $taxon) {
$child = $menu->addChild($taxon->getName(), $childOptions);
if ($taxonomy->getRoot()->hasPath()) {
$child->setLabelAttribute('data-image', $taxonomy->getRoot()->getPath());
if ($taxon->hasPath()) {
$child->setLabelAttribute('data-image', $taxon->getPath());
}
$this->createTaxonomiesMenuNode($child, $taxonomy->getRoot());
$this->createTaxonsMenuNode($child, $taxon);
}
$this->eventDispatcher->dispatch(MenuBuilderEvent::FRONTEND_TAXONOMIES, new MenuBuilderEvent($this->factory, $menu));
$this->eventDispatcher->dispatch(MenuBuilderEvent::FRONTEND_TAXONS, new MenuBuilderEvent($this->factory, $menu));
return $menu;
}
@ -362,7 +360,11 @@ class FrontendMenuBuilder extends MenuBuilder
return $menu;
}
protected function createTaxonomiesMenuNode(ItemInterface $menu, TaxonInterface $taxon)
/**
* @param ItemInterface $menu
* @param TaxonInterface $taxon
*/
protected function createTaxonsMenuNode(ItemInterface $menu, TaxonInterface $taxon)
{
foreach ($taxon->getChildren() as $child) {
$childMenu = $menu->addChild($child->getName(), [
@ -373,7 +375,7 @@ class FrontendMenuBuilder extends MenuBuilder
$childMenu->setLabelAttribute('data-image', $child->getPath());
}
$this->createTaxonomiesMenuNode($childMenu, $child);
$this->createTaxonsMenuNode($childMenu, $child);
}
}
}

View file

@ -48,13 +48,9 @@ sylius_backend_product_archetype:
resource: @SyliusWebBundle/Resources/config/routing/backend/product_archetype.yml
prefix: /product-archetypes
sylius_backend_taxonomy:
resource: @SyliusWebBundle/Resources/config/routing/backend/taxonomy.yml
prefix: /taxonomies
sylius_backend_taxon:
resource: @SyliusWebBundle/Resources/config/routing/backend/taxon.yml
prefix: /taxonomies/{taxonomyId}/taxons
prefix: /taxons
sylius_backend_user:
resource: @SyliusWebBundle/Resources/config/routing/backend/user.yml

View file

@ -1,6 +1,17 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
#
sylius_backend_taxon_index:
path: /
methods: [GET]
defaults:
_controller: sylius.controller.taxon:indexAction
_sylius:
template: SyliusWebBundle:Backend/Taxon:index.html.twig
paginate: false
repository:
method: findRootNodes
sylius_backend_taxon_create:
path: /new
methods: [GET, POST]
@ -8,12 +19,7 @@ sylius_backend_taxon_create:
_controller: sylius.controller.taxon:createAction
_sylius:
template: SyliusWebBundle:Backend/Taxon:create.html.twig
factory:
method: createForTaxonomy
arguments: $taxonomyId
redirect:
route: sylius_backend_taxonomy_show
parameters: {'id': $taxonomyId}
redirect: sylius_backend_taxon_index
sylius_backend_taxon_update:
path: /{id}/edit
@ -22,9 +28,16 @@ sylius_backend_taxon_update:
_controller: sylius.controller.taxon:updateAction
_sylius:
template: SyliusWebBundle:Backend/Taxon:update.html.twig
redirect:
route: sylius_backend_taxonomy_show
parameters: {'id': $taxonomyId}
redirect: sylius_backend_taxon_index
sylius_backend_taxon_delete:
path: /{id}
methods: [DELETE]
defaults:
_controller: sylius.controller.taxon:deleteAction
_sylius:
template: SyliusWebBundle:Backend/Misc:delete.html.twig
redirect: sylius_backend_taxon_index
sylius_backend_taxon_product_index:
path: /{id}/products
@ -35,13 +48,10 @@ sylius_backend_taxon_product_index:
template: SyliusWebBundle:Backend/Taxon:productIndex.html.twig
paginate: 30
sylius_backend_taxon_delete:
sylius_backend_taxon_show:
path: /{id}
methods: [DELETE]
methods: [GET]
defaults:
_controller: sylius.controller.taxon:deleteAction
_controller: sylius.controller.taxon:showAction
_sylius:
template: SyliusWebBundle:Backend/Misc:delete.html.twig
redirect:
route: sylius_backend_taxonomy_show
parameters: {'id': $taxonomyId}
template: SyliusWebBundle:Backend/Taxon:show.html.twig

Some files were not shown because too many files have changed in this diff Show more