imports:
    - { resource: security.yml }

framework:
    secret:                           "dunglas.fr"
    router:
        resource:                     "%kernel.root_dir%/config/routing.yml"
        strict_requirements:          "%kernel.debug%"
    validation:
        enable_annotations:            true
    serializer:
        enable_annotations:            true
    trusted_proxies: ~
    test: ~
    session:
        storage_id:                    "session.storage.mock_file"

doctrine:
    dbal:
        driver:                        "pdo_sqlite"
        path:                          "%kernel.cache_dir%/db.sqlite"
        charset:                       "UTF8"

    orm:
        auto_generate_proxy_classes:   "%kernel.debug%"
        auto_mapping:                  true

dunglas_api:
    title:                             "My Dummy API"
    description:                       "This is a test API."
    supported_formats:                 [ "jsonld", "xml" ]
    enable_fos_user:                   true
    collection:
        filter_name:
            order:                     "order"
        order:                         "ASC"
        pagination:
            client_can_enable:         true
            items_per_page:
                default:               3
                client_can_change:     true

fos_user:
    db_driver:        orm
    firewall_name:    api
    service:
        user_manager: api.user_manager
    user_class:       "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\User"

services:
    api.user_manager:
        class: "Dunglas\ApiBundle\Tests\Behat\TestBundle\Manager\UserManager"
        arguments:
            -  @security.encoder_factory
            -  @fos_user.util.username_canonicalizer
            -  @fos_user.util.email_canonicalizer
            -  @fos_user.entity_manager
            -  %fos_user.model.user.class%

    fos_user.mailer.default:
        class: "Dunglas\ApiBundle\Tests\Mock\MailerMock"

    api.name_converter:
        class: "Dunglas\ApiBundle\Tests\Behat\TestBundle\Serializer\\NameConverter\CustomConverter"

    xml_responder_view_listener:
        class: "Dunglas\ApiBundle\Tests\Behat\TestBundle\EventListener\XmlResponderViewListener"
        arguments:
            - @api.serializer
        tags:
            - { name: "kernel.event_listener", event: "kernel.view", method: "onKernelView" }

    user:
        parent:                      "api.resource"
        arguments:                   [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\User" ]
        calls:
                                     - method:    "initNormalizationContext"
                                       arguments: [ { groups: [ "user", "user-read" ] } ]
                                     - method:    "initDenormalizationContext"
                                       arguments: [ { groups: [ "user", "user-write" ] } ]
        tags:                        [ { name: "api.resource" } ]

    ressource.date_filter:
        parent:    "api.doctrine.orm.date_filter"
        arguments: [ { "dummyDate": ~ } ]

    my_dummy_resource.search_filter:
        parent:                     "api.doctrine.orm.search_filter"
        arguments:                  [ { "id": "exact", "name": "partial", "relatedDummies": "exact" } ]

    my_dummy_resource.order_filter:
        parent:                     "api.doctrine.orm.order_filter"
        arguments:                  [ { "id": ~, "name": "desc" } ]

    my_dummy_resource.date_filter:
            parent:                 "api.doctrine.orm.date_filter"
            arguments:              [ { "dummyDate": ~ } ]

    my_dummy_resource:
        parent:                      "api.resource"
        arguments:                   [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\Dummy" ]
        calls:
                                     - method:    "initFilters"
                                       arguments: [ [ "@my_dummy_resource.search_filter", "@my_dummy_resource.order_filter", "@my_dummy_resource.date_filter" ] ]
        tags:                        [ { name: "api.resource" } ]

    my_related_dummy_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\RelatedDummy" ]
        tags:                       [ { name: "api.resource" } ]

    my_relation_embedder_resource.item_operation.get:
        class:                      "Dunglas\ApiBundle\Api\Operation\Operation"
        public:                     false
        factory:                    [ "@api.operation_factory", "createItemOperation" ]
        arguments:                  [ "@my_relation_embedder_resource", "GET" ]

    my_relation_embedder_resource.item_operation.put:
        class:                      "Dunglas\ApiBundle\Api\Operation\Operation"
        public:                     false
        factory:                    [ "@api.operation_factory", "createItemOperation" ]
        arguments:                  [ "@my_relation_embedder_resource", "PUT" ]

    my_relation_embedder_resource.item_operation.custom_get:
        class:                      "Dunglas\ApiBundle\Api\Operation\Operation"
        public:                     false
        factory:                    [ "@api.operation_factory", "createItemOperation" ]
        arguments:
                                    - "@my_relation_embedder_resource"
                                    - [ "GET", "HEAD" ]
                                    - "/relation_embedders/{id}/custom"
                                    - "TestBundle:Custom:custom"
                                    - "my_custom_route"
                                    -
                                        "@type":       "hydra:Operation"
                                        "hydra:title": "A custom operation"
                                        "returns":     "xmls:string"

    my_relation_embedder_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\RelationEmbedder" ]
        calls:
                                    - method:    "initNormalizationContext"
                                      arguments:
                                          -      { groups: [ "barcelona" ] }
                                    - method:    "initDenormalizationContext"
                                      arguments:
                                          -      { groups: [ "chicago" ] }
                                    - method:    "initItemOperations"
                                      arguments:
                                          -
                                              -      "@my_relation_embedder_resource.item_operation.get"
                                              -      "@my_relation_embedder_resource.item_operation.put"
                                              -      "@my_relation_embedder_resource.item_operation.custom_get"
        tags:                       [ { name: "api.resource" } ]

    custom_resource:
        parent:                     "api.resource"
        class:                      "Dunglas\ApiBundle\Tests\Behat\TestBundle\Api\CustomResource"
        tags:                       [ { name: "api.resource" } ]

    third_level_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\ThirdLevel" ]
        tags:                       [ { name: "api.resource" } ]

    circular_reference_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\CircularReference" ]
        calls:
                                    - method:    "initNormalizationContext"
                                      arguments:
                                          -      { groups: [ "circular" ] }
        tags:                       [ { name: "api.resource" } ]

    custom_identifier_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\CustomIdentifierDummy" ]
        tags:                       [ { name: "api.resource" } ]

    custom_writable_identifier_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\CustomWritableIdentifierDummy" ]
        tags:                       [ { name: "api.resource" } ]

    custom_normalized_resource:
        parent:                     "api.resource"
        arguments:                  [ "Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\CustomNormalizedDummy" ]
        calls:
                                    - method:    "initNormalizationContext"
                                      arguments:
                                          -      { groups: [ "output" ] }
                                    - method:    "initDenormalizationContext"
                                      arguments:
                                          -      { groups: [ "input" ] }
        tags:                       [ { name: "api.resource" } ]

    no_collection_resource:
        parent:                     "api.resource"
        arguments:                  [ 'Dunglas\ApiBundle\Tests\Behat\TestBundle\Entity\NoCollectionDummy' ]
        tags:                       [ { name: "api.resource" } ]
        calls:
                                    - method:    "initCollectionOperations"
                                      arguments:
                                            - []
