<?xml version="1.0"?>
<!--
/**
 * Copyright © Magefan (support@magefan.com). All rights reserved.
 * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
 *
 * Glory to Ukraine! Glory to the heroes!
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="Magefan\Blog\Api\AuthorInterface" type="Magefan\Blog\Model\Author" />
    <preference for="Magefan\Blog\Api\AuthorResourceModelInterface" type="Magefan\Blog\Model\ResourceModel\Author" />
    <preference for="Magefan\Blog\Api\AuthorCollectionInterface" type="Magefan\Blog\Model\ResourceModel\Author\Collection" />
    <preference for="Magefan\Blog\Api\SitemapConfigInterface" type="Magefan\Blog\Model\Sitemap\SitemapConfig" />
    <preference for="Magefan\Blog\Api\PostManagementInterface" type="Magefan\Blog\Model\PostManagement" />
    <preference for="Magefan\Blog\Api\CategoryManagementInterface" type="Magefan\Blog\Model\CategoryManagement" />
    <preference for="Magefan\Blog\Api\PostRepositoryInterface" type="Magefan\Blog\Model\PostRepository" />
    <preference for="Magefan\Blog\Api\CategoryRepositoryInterface" type="Magefan\Blog\Model\CategoryRepository" />
    <preference for="Magefan\Blog\Api\TagRepositoryInterface" type="Magefan\Blog\Model\TagRepository" />
    <preference for="Magefan\Blog\Api\AuthorRepositoryInterface" type="Magefan\Blog\Model\AuthorRepository" />
    <preference for="Magefan\Blog\Api\CommentRepositoryInterface" type="Magefan\Blog\Model\CommentRepository" />
    <!-- deprecated <preference for="Magento\Sitemap\Model\Sitemap" type="Magefan\Blog\Model\Sitemap" /> -->
    <preference for="Magefan\Blog\Api\UrlResolverInterface" type="Magefan\Blog\Model\UrlResolver" />
    <virtualType name="Magefan\Blog\ImageUpload" type="Magefan\Blog\Model\ImageUploader">
        <arguments>
            <argument name="baseTmpPath" xsi:type="string">magefan_blog/tmp</argument>
            <argument name="basePath" xsi:type="string">magefan_blog</argument>
            <argument name="allowedExtensions" xsi:type="array">
                <item name="jpg" xsi:type="string">jpg</item>
                <item name="jpeg" xsi:type="string">jpeg</item>
                <item name="gif" xsi:type="string">gif</item>
                <item name="png" xsi:type="string">png</item>
            </argument>
        </arguments>
    </virtualType>
    <type name="Magefan\Blog\Controller\Adminhtml\Post\Upload\FeaturedImg">
        <arguments>
            <argument name="imageUploader" xsi:type="object">Magefan\Blog\ImageUpload</argument>
        </arguments>
    </type>
    <type name="Magefan\Blog\Controller\Adminhtml\Post\Upload\OgImg">
        <arguments>
            <argument name="imageUploader" xsi:type="object">Magefan\Blog\ImageUpload</argument>
        </arguments>
    </type>
    <type name="Magefan\Blog\Controller\Adminhtml\Post\Upload\Gallery">
        <arguments>
            <argument name="imageUploader" xsi:type="object">Magefan\Blog\ImageUpload</argument>
        </arguments>
    </type>

    <type name="Magento\Sitemap\Model\Sitemap">
        <plugin name="magento_sitemap_model_sitemap_magefan_blog"
                type="Magefan\Blog\Plugin\Magento\Sitemap\SitemapPlugin" sortOrder="10"/>
    </type>

    <type name="MageWorx\XmlSitemap\Model\Sitemap">
        <plugin name="mageworks_sitemap_model_sitemap_magefan_blog"
                type="Magefan\Blog\Plugin\Magento\Sitemap\SitemapPlugin" sortOrder="10"/>
    </type>

    <type name="Magento\AdminGws\Model\Models">
        <plugin name="magefan_blog_plugin_admingws_model_models_plugin" type="\Magefan\Blog\Plugin\Magento\AdminGws\Model\ModelsPlugin" sortOrder="10"/>
    </type>
    
    <virtualType name="Magefan\Blog\Block\Widget\PostLink" type="Magefan\Blog\Block\Widget\Link">
        <arguments>
            <argument name="modelRepository" xsi:type="object">Magefan\Blog\Api\PostRepositoryInterface</argument>
        </arguments>
    </virtualType>
    <virtualType name="Magefan\Blog\Block\Widget\CategoryLink" type="Magefan\Blog\Block\Widget\Link">
        <arguments>
            <argument name="modelRepository" xsi:type="object">Magefan\Blog\Api\CategoryRepositoryInterface</argument>
        </arguments>
    </virtualType>
    <virtualType name="Magefan\Blog\Block\Widget\TagLink" type="Magefan\Blog\Block\Widget\Link">
        <arguments>
            <argument name="modelRepository" xsi:type="object">Magefan\Blog\Api\TagRepositoryInterface</argument>
        </arguments>
    </virtualType>
    <virtualType name="Magefan\Blog\Block\Widget\AuthorLink" type="Magefan\Blog\Block\Widget\Link">
        <arguments>
            <argument name="modelRepository" xsi:type="object">Magefan\Blog\Api\AuthorRepositoryInterface</argument>
        </arguments>
    </virtualType>
</config>
