Zend certified PHP/Magento developer

How to modify datasource of CMS page

I added some custom fields in the admin cms page form. Also, I added an observer to be able to save my custom fields into my custom table. However, I am now at my final step and I can’t seem to modify the datasource of the cms page form. I did it for the Catalog module, but there’s no “pool” inside the cms page module.

Here is what I did so far in my custom module:

di.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <virtualType name="MagentoCmsUiDataProviderPageFormModifierPool" type="MagentoUiDataProviderModifierPool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="newFields" xsi:type="array">
                    <item name="class" xsi:type="string">
                        My_moduleCustomFieldsUiDataProviderPageFormModifierFields
                    </item>
                    <item name="sortOrder" xsi:type="number">100</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
    
</config>

Ui/DataProvider/Page/Form/Modifier/Fields.php

namespace My_moduleCustomFieldsUiDataProviderPageFormModifier;

use MagentoCmsUiComponentDataProvider;
use MagentoCatalogModelPageFactory;
use My_moduleCustomFieldsModelPagesFactory;

class Fields extends DataProvider
{
    protected $cfFactory;

    public function __construct(
        PagesFactory $cfFactory
    ) {
        $this->cfFactory = $cfFactory;
    }

    public function modifyData(array $data)
    {

        var_dump('test');
        die();

        return $data;
    }

    public function modifyMeta(array $meta)
    {
        return $meta;
    }
}

If I add a var_dump + die() in my other module for the products, it works fine. Before the page is loaded, I can see my var_dump. But it’s not working for the pages. Any idea?