first commit

This commit is contained in:
2025-07-22 15:41:16 +02:00
commit 2a40a54622
81 changed files with 5614 additions and 0 deletions

View File

@ -0,0 +1,95 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Circolari
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
* @copyright 2025 Tommaso Cippitelli
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Pcrt\Component\Circolari\Site\Service;
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Component\Router\RouterViewConfiguration;
use Joomla\CMS\Component\Router\RouterView;
use Joomla\CMS\Component\Router\Rules\StandardRules;
use Joomla\CMS\Component\Router\Rules\NomenuRules;
use Joomla\CMS\Component\Router\Rules\MenuRules;
use Joomla\CMS\Factory;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Categories\CategoryInterface;
use Joomla\Database\DatabaseInterface;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\CMS\Component\ComponentHelper;
/**
* Class CircolariRouter
*
*/
class Router extends RouterView
{
private $noIDs;
/**
* The category factory
*
* @var CategoryFactoryInterface
*
* @since 1.0.0
*/
private $categoryFactory;
/**
* The category cache
*
* @var array
*
* @since 1.0.0
*/
private $categoryCache = [];
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
{
$params = ComponentHelper::getParams('com_circolari');
$this->noIDs = (bool) $params->get('sef_ids');
$this->categoryFactory = $categoryFactory;
parent::__construct($app, $menu);
$this->attachRule(new MenuRules($this));
$this->attachRule(new StandardRules($this));
$this->attachRule(new NomenuRules($this));
}
/**
* Method to get categories from cache
*
* @param array $options The options for retrieving categories
*
* @return CategoryInterface The object containing categories
*
* @since 1.0.0
*/
private function getCategories(array $options = []): CategoryInterface
{
$key = serialize($options);
if (!isset($this->categoryCache[$key]))
{
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
}
return $this->categoryCache[$key];
}
}