<?xml version="1.0"?>
<!--
/**
 * Regenerate Url Rewrites
 *
 * @package OlegKoval_RegenerateUrlRewrites
 * @author Oleg Koval <olegkoval.ca@gmail.com>
 * @copyright 2017-2067 Oleg Koval
 * @license OSL-3.0, AFL-3.0
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="OlegKoval\RegenerateUrlRewrites\Api\RegenerateServiceInterface" type="OlegKoval\RegenerateUrlRewrites\Model\RegenerateService"/>
    <!-- every bin/magento call constructs all commands: create the service (indexer config etc.) only when run -->
    <type name="OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites">
        <arguments>
            <argument name="regenerateService" xsi:type="object">OlegKoval\RegenerateUrlRewrites\Api\RegenerateServiceInterface\Proxy</argument>
            <argument name="consoleMessages" xsi:type="object">OlegKoval\RegenerateUrlRewrites\Model\Notification\ConsoleMessages\Proxy</argument>
        </arguments>
    </type>
    <!-- the feed lives in its own repository, so every release reads the current messages;
         "edition" is replaced by an add-on edition's di.xml to get that edition's items instead of these -->
    <type name="OlegKoval\RegenerateUrlRewrites\Model\Notification\FeedSource">
        <arguments>
            <argument name="feedUrl" xsi:type="string">https://raw.githubusercontent.com/olegkoval/magento-extension-notifications/main/regenerate-url-rewrites.xml</argument>
            <argument name="audiences" xsi:type="array">
                <item name="edition" xsi:type="string">free</item>
                <item name="everyone" xsi:type="string">all</item>
            </argument>
        </arguments>
    </type>
    <!-- a dry run must not continue on a reconnected (autocommitting) connection -->
    <type name="Magento\Framework\DB\Adapter\Pdo\Mysql">
        <plugin name="olegkoval_regenerateurlrewrites_dry_run_guard" type="OlegKoval\RegenerateUrlRewrites\Plugin\DryRunConnectionGuard"/>
    </type>
    <type name="Magento\Framework\Console\CommandListInterface">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="ok:urlrewrites:regenerate" xsi:type="object">OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites</item>
            </argument>
        </arguments>
    </type>
</config>
