sylius_admin_ajax_taxon_root_nodes:
    path: /root-nodes
    methods: [GET]
    defaults:
        _controller: sylius.controller.taxon::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findRootNodes

sylius_admin_ajax_taxon_leafs:
    path: /leafs
    methods: [GET]
    defaults:
        _controller: sylius.controller.taxon::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findChildren
                arguments:
                    parentCode: $parentCode

sylius_admin_ajax_taxon_by_code:
    path: /leaf
    methods: [GET]
    defaults:
        _controller: sylius.controller.taxon::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findBy
                arguments: [code: $code]

sylius_admin_ajax_taxon_by_name_phrase:
    path: /search
    methods: [GET]
    defaults:
        _controller: sylius.controller.taxon::indexAction
        _format: json
        _sylius:
            serialization_groups: [Autocomplete]
            permission: true
            repository:
                method: findByNamePart
                arguments:
                    phrase: expr:service('request_stack').getCurrentRequest().query.get('phrase', '')
                    locale: null
                    limit: 25

sylius_admin_ajax_generate_taxon_slug:
    path: /generate-slug/
    methods: [GET]
    defaults:
        _controller: sylius.controller.taxon_slug::generateAction
        _format: json

# This route is deprecated since Sylius 1.13.0 and will be removed in 2.0.0.
sylius_admin_ajax_taxon_move:
    path: /{id}/move
    methods: [PUT]
    defaults:
        _controller: sylius.controller.taxon::updateAction
        _format: json
        _sylius:
            permission: true
            form: Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonPositionType

sylius_admin_ajax_taxon_move_up:
    path: /{id}/move-up
    methods: [PUT]
    defaults:
        _controller: sylius.controller.taxon_position::moveUpAction
        _format: json
        _sylius:
            permission: true

sylius_admin_ajax_taxon_move_down:
    path: /{id}/move-down
    methods: [PUT]
    defaults:
        _controller: sylius.controller.taxon_position::moveDownAction
        _format: json
        _sylius:
            permission: true
