<commit_before># Wieni Controller

Use bundle-specific controllers for nodes and taxonomies.

## Installation

```
composer require wieni\wmcontroller
drush en wmcontroller
```

Visit `/admin/config/services/wmcontroller` and tell wmcontroller in which module it has to look for bundle-specific controllers.

### Controllers

Create bundle-specific controllers with the following convention:

`src\Controller\<entityType>\<bundle>Controller`

`<entityType>` and `<bundle>` are **singular and camelCased**.

For example:

`src\Controller\TaxonomyTerm\CategoryController` will be matched against a `taxonomy_term` with bundle `categories`.

We will call the `show()` method on your controller, so make sure your controller has this method.

```
// src/Controller/Node/ArticleController.php
<?php

namespace Drupal\mymodule\Controller\Node;

use Drupal\Core\Controller\ControllerBase;

class ArticleController extends ControllerBase
{

    public function show($node)
    {
        return [
            '#markup' => "Hello, i'm $node->id()"
        ];
    }

}
```

## Caching

Handles full page cache for anonymous users.

Kind of reinvents the page_cache wheel but handles cache tags automatically
if you don't like drupal's way of rendering and use twig as it was meant to
be used:

Inject your models and use includes instead of the filthy theme suggestions.


To enable: set `wmcontroller.cache.store` and `wmcontroller.cache.tags` to true.

*Note*: we currently only disable the page_cache middleware if you're allowing
wmcontroller to handle page cache. Render cache on the other hand we don't
interfere with as it's up to you assess whether there's a need for it or not.

Disabling the entire render cache is a simple as setting
`$settings['cache']['bins']['render']` to a noop backend in settings.php.


*Note2*: automatic adding of entity tags requires you to inject each entity
in the root of the array you pass to twig's include call.
This seems a natural/logical way to structure you templates anyway,
so pretty minor issue imo.


```twig
{{ article.getTitle() }}
{% for paragraph in article.getParagraphs() %}
    {%
        include '@thing/article/paragraph/small.html.twig'
        with {paragraph: paragraph} only
    %}
{% endfor %}
```
<commit_msg>README: query param ignore note<commit_after># Wieni Controller

Use bundle-specific controllers for nodes and taxonomies.

## Installation

```
composer require wieni\wmcontroller
drush en wmcontroller
```

Visit `/admin/config/services/wmcontroller` and tell wmcontroller in which module it has to look for bundle-specific controllers.

### Controllers

Create bundle-specific controllers with the following convention:

`src\Controller\<entityType>\<bundle>Controller`

`<entityType>` and `<bundle>` are **singular and camelCased**.

For example:

`src\Controller\TaxonomyTerm\CategoryController` will be matched against a `taxonomy_term` with bundle `categories`.

We will call the `show()` method on your controller, so make sure your controller has this method.

```
// src/Controller/Node/ArticleController.php
<?php

namespace Drupal\mymodule\Controller\Node;

use Drupal\Core\Controller\ControllerBase;

class ArticleController extends ControllerBase
{

    public function show($node)
    {
        return [
            '#markup' => "Hello, i'm $node->id()"
        ];
    }

}
```

## Caching

Handles full page cache for anonymous users.

Kind of reinvents the page_cache wheel but handles cache tags automatically
if you don't like drupal's way of rendering and use twig as it was meant to
be used:

Inject your models and use includes instead of the filthy theme suggestions.


To enable: set `wmcontroller.cache.store` and `wmcontroller.cache.tags` to true.

*Note*: we currently only disable the page_cache middleware if you're allowing
wmcontroller to handle page cache. Render cache on the other hand we don't
interfere with as it's up to you assess whether there's a need for it or not.

Disabling the entire render cache is a simple as setting
`$settings['cache']['bins']['render']` to a noop backend in settings.php.


*Note2*: automatic adding of entity tags requires you to inject each entity
in the root of the array you pass to twig's include call.
This seems a natural/logical way to structure you templates anyway,
so pretty minor issue imo.

*Note3*: to mitigate query param 'attacks' they are ignored.


```twig
{{ article.getTitle() }}
{% for paragraph in article.getParagraphs() %}
    {%
        include '@thing/article/paragraph/small.html.twig'
        with {paragraph: paragraph} only
    %}
{% endfor %}
```

{'fraction_non_alphanumeric': 0.0896267361111111, 'fraction_numerical': 0.0006510416666666666, 'mean_word_length': 4.2494305239179955, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '3032046', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1248, 'n_words': 535}