public static function getControllerAndAction($vendor, $module, $action, $scope = Controller::SCOPE_AJAX)
{
$parts = explode('.', $action);
$actionName = array_pop($parts);
$controllerClass = self::buildControllerClassName($vendor, $module, $parts);
try
{
$reflectionClass = new \ReflectionClass($controllerClass);
if ($reflectionClass->isAbstract())
{
return null;
}
if (!$reflectionClass->isSubclassOf(Controller::className()))
{
return null;
}
/** @var Controller $controller */
/** @see \Bitrix\Main\Engine\Controller::__construct */
$controller = $reflectionClass->newInstance();
$controller->setScope($scope);
$controller->setCurrentUser(CurrentUser::get());
return array($controller, $actionName);
}
catch (\ReflectionException $exception)
{echo "<pre>".print_r($exception, 1)."</pre>"; die();}
return null;
}
ReflectionException Object
(
[message:protected] => Class \Petrov\Main\Controller\BasketActions does not exist
[string:Exception:private] =>
[code:protected] => -1
[file:protected] => /home/bitrix/www/bitrix/modules/main/lib/engine/resolver.php
[line:protected] => 30
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /home/bitrix/www/bitrix/modules/main/lib/engine/resolver.php
[line] => 30
[function] => __construct
[class] => ReflectionClass
[type] => ->
[args] => Array
(
[0] => \Petrov\Main\Controller\BasketActions
)
)
[1] => Array
(
[file] => /home/bitrix/www/bitrix/modules/main/lib/engine/router.php
[line] => 142
[function] => getControllerAndAction
[class] => Bitrix\Main\Engine\Resolver
[type] => ::
[args] => Array
(
[0] => petrov
[1] => petrov.main
[2] => mapi.BasketActions.getAnalogs
)
)
[2] => Array
(
[file] => /home/bitrix/www/bitrix/modules/main/lib/httpapplication.php
[line] => 110
[function] => getControllerAndAction
[class] => Bitrix\Main\Engine\Router
[type] => ->
[args] => Array
(
)
)
[3] => Array
(
[file] => /home/bitrix/www/bitrix/modules/main/services/ajax.php
[line] => 17
[function] => run
[class] => Bitrix\Main\HttpApplication
[type] => ->
[args] => Array
(
)
)
[4] => Array
(
[file] => /home/bitrix/www/bitrix/services/main/ajax.php
[line] => 1
[args] => Array
(
[0] => /home/bitrix/www/bitrix/modules/main/services/ajax.php
)
[function] => require
)
)
[previous:Exception:private] =>
)
"[Bitrix\Main\SystemException]
Could not find description of mapi.BasketActions.getAnalogs in Bitrix\Main\Engine\DefaultController (22002)
/home/bitrix/www/bitrix/modules/main/lib/engine/controller.php:454
#0: Bitrix\Main\Engine\Controller->create(string)
/home/bitrix/www/bitrix/modules/main/lib/engine/controller.php:258
#1: Bitrix\Main\Engine\Controller->run(string, array)
/home/bitrix/www/bitrix/modules/main/lib/httpapplication.php:118
#2: Bitrix\Main\HttpApplication->run()
/home/bitrix/www/bitrix/modules/main/services/ajax.php:17
#3: require(string)
/home/bitrix/www/bitrix/services/main/ajax.php:1
----------"
private static function getPathConfigForModule($moduleId)
{
if (!$moduleId || !Main\ModuleManager::isModuleInstalled($moduleId))
{
return false;
}
$moduleConfigPath = getLocalPath("modules/{$moduleId}/.settings.php");
if ($moduleConfigPath === false)
{
return false;
}
return static::getPath($moduleConfigPath);
}
$moduleConfigPath = "/local/modules/petrov.main/.settings.php"
static::getPath возвращает абсолютный путь
/home/bitrix/www/local/modules/petrov.main/.settings.php
arr_for_send = [0x03, 0xE8, 0x01]
str_for_send = ''.join('{:02X}'.format(a) for a in arr_for_send) + chr(0x7F) +".\r\n"
#print(str_for_send)
ser.write(str_for_send )
Роман Грицук, PetrPo спасибо всем )