<?php
/*
 *   @extension       YRPrice Calculator
 *   @author          Lev Milicenco<support@marlev.it>
 *   @link            http://www.marlev.it
 *   @copyright       Copyright 2023 marlev.it All Rights Reserved
 *   @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 *

 */
//for_use

namespace Marlev\Component\Tmarlevv2\Administrator\Extension;


defined('_JEXEC') or die;

use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Association\AssociationServiceInterface;
use Joomla\CMS\Association\AssociationServiceTrait;
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Categories\CategoryServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use FooNamespace\Component\Foos\Administrator\Service\HTML\AdministratorService;
use FooNamespace\Component\Foos\Administrator\Service\HTML\Icon;
use Psr\Container\ContainerInterface;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Component\Router\RouterServiceInterface;
use Joomla\CMS\Component\Router\RouterServiceTrait;

/**
 * Component class for com_foos
 *
 * @since  __BUMP_VERSION__
 */
class Tmarlevv2Component extends MVCComponent implements BootableExtensionInterface, AssociationServiceInterface, RouterServiceInterface
{
   // use CategoryServiceTrait;
    use AssociationServiceTrait;
    use HTMLRegistryAwareTrait;
    use RouterServiceTrait;

    /**
     * Booting the extension. This is the function to set up the environment of the extension like
     * registering new class loaders, etc.
     *
     * If required, some initial set up can be done from services of the container, eg.
     * registering HTML services.
     *
     * @param   ContainerInterface  $container  The container
     *
     * @return  void
     *
     * @since   __BUMP_VERSION__
     */
    public function boot(ContainerInterface $container)
    {
        //$this->getRegistry()->register('foosadministrator', new AdministratorService);
        //$this->getRegistry()->register('fooicon', new Icon($container->get(SiteApplication::class)));
    }

    /**
     * Adds Count Items for Category Manager.
     *
     * @param   \stdClass[]  $items    The category objects
     * @param   string       $section  The section
     *
     * @return  void
     *
     * @since   __BUMP_VERSION__
     */
    public function countItems(array $items, string $section)
    {
        /*try {
            $config = (object) [
                'related_tbl'   => $this->getTableNameForSection($section),
                'state_col'     => 'published',
                'group_col'     => 'catid',
                'relation_type' => 'category_or_group',
            ];

            ContentHelper::countRelations($items, $config);
        } catch (\Exception $e) {
            // Ignore it
        }*/
    }

    /**
     * Returns the table for the count items functions for the given section.
     *
     * @param   string  $section  The section
     *
     * @return  string|null
     *
     * @since   __BUMP_VERSION__
     */
    protected function getTableNameForSection(string $section = null)
    {
        //return ($section === 'category' ? 'categories' : 'foos_details');
    }

    /**
     * Returns the state column for the count items functions for the given section.
     *
     * @param   string  $section  The section
     *
     * @return  string|null
     *
     * @since   __BUMP_VERSION__
     */
    protected function getStateColumnForSection(string $section = null)
    {
        //return 'published';
    }
}