Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/catalog/lib/Access/Rule/Factory/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/catalog/lib/Access/Rule/Factory/CatalogRuleFactory.php

<?php

namespace Bitrix\Catalog\Access\Rule\Factory;

use Bitrix\Catalog\Access\ActionDictionary;
use Bitrix\Main\Access\AccessibleController;
use Bitrix\Main\Access\Rule\Factory\RuleControllerFactory;

class CatalogRuleFactory extends RuleControllerFactory
{
	protected const BASE_RULE = 'Base';

	protected function getClassName(string $action, AccessibleController $controller): ?string
	{
		$actionName = ActionDictionary::getActionRuleName($action);
		if (!$actionName)
		{
			return null;
		}

		$action = explode('_', $actionName);
		$action = array_map(fn($el) => ucfirst(mb_strtolower($el)), $action);

		$ruleClass = $this->getNamespace($controller) . implode($action) . static::SUFFIX;

		if (class_exists($ruleClass))
		{
			return $ruleClass;
		}

		return $this->getNamespace($controller) . static::BASE_RULE . static::SUFFIX;
	}
}