<commit_before># Operations

By default, the following operations are automatically enabled:

*Collection*

| Method | Description                               |
|--------|-------------------------------------------|
| `GET`  | Retrieve the (paginated) list of elements |
| `POST` | Create a new element                      |

*Item*

| Method   | Description                               |
|----------|-------------------------------------------|
| `GET`    | Retrieve element (mandatory operation)    |
| `PUT`    | Update an element                         |
| `DELETE` | Delete an element                         |


## Disabling operations

If you want to disable some operations (e.g. the `DELETE` operation), you must register manually applicable operations using
the operation factory class, `Dunglas\ApiBundle\Resource::addCollectionOperation()` and `Dunglas\ApiBundle\Resource::addCollectionOperation()`
methods.

The following `Resource` definition exposes a `GET` operation for it's collection but not the `POST` one:

```yaml
services:
    resource.product.collection_operation.get:
        class:     "Dunglas\ApiBundle\Api\Operation\Operation"
        public:    false
        factory:   [ "@api.operation_factory", "createCollectionOperation" ]
        arguments: [ "@resource.product", "GET" ]

    resource.product:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Product" ]
        calls:
            -      [ "initCollectionOperations", [ [ "@resource.product.collection_operation.get" ] ] ]
        tags:      [ { name: "api.resource" } ]
```

However, in the following example items operations will still be automatically registered. To disable them, call `initItemOperations`
with an empty array as first parameter:

```yaml
# ...

    resource.product:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Product" ]
        calls:
            -      [ "initItemOperations", [ [ ] ] ]
            -      [ "initCollectionOperations", [ [ "@resource.product.collection_operation.get" ] ] ]<commit_msg>Docs: Correct and update doc about operation disabling<commit_after># Operations

By default, the following operations are automatically enabled:

*Collection*

| Method | Description                               |
|--------|-------------------------------------------|
| `GET`  | Retrieve the (paginated) list of elements |
| `POST` | Create a new element                      |

*Item*

| Method   | Description                               |
|----------|-------------------------------------------|
| `GET`    | Retrieve element (mandatory operation)    |
| `PUT`    | Update an element                         |
| `DELETE` | Delete an element                         |


## Disabling operations

If you want to disable some operations (e.g. the `DELETE` operation), you must create manually applicable operations using
the operation factory class, `Dunglas\ApiBundle\Api\Operation\OperationFactory::createCollectionOperation()` or/and `Dunglas\ApiBundle\Api\Operation\OperationFactory::createItemOperation()` methods and then, register it in the resource with `Dunglas\ApiBundle\Api/Resource::initCollectionOperations` or/and `Dunglas\ApiBundle\Api/Resource::initItemOperations`.

The following `Resource` definition exposes a `GET` operation for it's collection but not the `POST` one:

```yaml
services:
    resource.product.collection_operation.get:
        class:     "Dunglas\ApiBundle\Api\Operation\Operation"
        public:    false
        factory:   [ "@api.operation_factory", "createCollectionOperation" ]
        arguments: [ "@resource.product", "GET" ]

    resource.product:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Product" ]
        calls:
            -      [ "initCollectionOperations", [ [ "@resource.product.collection_operation.get" ] ] ]
        tags:      [ { name: "api.resource" } ]
```

However, in the following example items operations will still be automatically registered. To disable them, call `initItemOperations`
with an empty array as first parameter:

```yaml
# ...

    resource.product:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Product" ]
        calls:
            -      [ "initItemOperations", [ [ ] ] ]
            -      [ "initCollectionOperations", [ [ "@resource.product.collection_operation.get" ] ] ]
{'fraction_non_alphanumeric': 0.151183970856102, 'fraction_numerical': 0.0, 'mean_word_length': 2.2042304886943835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3279039', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1075, 'n_words': 304}