- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/operation.php
- Класс: BitrixTasksDispatcherOperation
- Вызов: Operation::checkClass
protected function checkClass()
{
$noEntity = false;
if(class_exists($this->parsed['CLASS']) && is_subclass_of($this->parsed['CLASS'], 'TasksBaseComponent'))
{
// its a component class. Such class can not be loaded by autoloader, so it must be pre-loaded above
$class = $this->parsed['CLASS'];
$allowedMethods = $class::getAllowedMethods();
if(!is_array($allowedMethods))
{
throw new BitrixTasksException('Method '.$class.'::allowedMethods() returned a non-array value, too frightful to execute');
}
else
{
$allowedMethods = array_flip($allowedMethods);
$allowedMethods = array_change_key_case($allowedMethods, CASE_LOWER);
}
// in the component class the easiest way to control accessibility of methods is the white-list,
// because there are also huge amount of methods that can be potentially called by mistake
if(!isset($allowedMethods[$this->parsed['METHOD']]))
{
$this->addParseError('Method is not allowed to call: '.$this->parsed['FULLPATH']);
return;
}
}
else
{
$this->parsed['CLASS'] = '\'.$this->namespace.'\'.$this->parsed['CLASS'];
// in the callable class each public method is meant to be callable outside, and only few methods are not, so the black-list here
if(class_exists($this->parsed['CLASS']) && is_subclass_of($this->parsed['CLASS'], 'BitrixTasksDispatcherPublicAction'))
{
$class = $this->parsed['CLASS'];
$forbiddenMethods = $class::getForbiddenMethods();
if(!is_array($forbiddenMethods))
{
throw new BitrixTasksException('Method '.$class.'::getForbiddenMethods() returned a non-array value, too frightful to execute');
}
else
{
$forbiddenMethods = array_flip($forbiddenMethods);
$forbiddenMethods = array_change_key_case($forbiddenMethods, CASE_LOWER);
}
if(isset($forbiddenMethods[$this->parsed['METHOD']]))
{
$this->addParseError('Method is not allowed to call: '.$this->parsed['FULLPATH']);
return;
}
}
else
{
$noEntity = true;
$this->addParseError('Entity not found: '.$this->parsed['ENTITY']);
}
}
if(!$noEntity && !$this->isCallable())
{
$this->addParseError('Method not found or not callable: '.$this->parsed['FULLPATH']);
}
}