- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/orm/objectify/collection.php
- Класс: BitrixMainORMObjectifyCollection
- Вызов: Collection::__call
public function __call($name, $arguments)
{
$first3 = substr($name, 0, 3);
$last4 = substr($name, -4);
// group getter
if ($first3 == 'get' && $last4 == 'List')
{
$fieldName = EntityObject::sysMethodToFieldCase(substr($name, 3, -4));
if ($fieldName == '')
{
$fieldName = StringHelper::strtoupper($arguments[0]);
// check if custom method exists
$personalMethodName = $first3.EntityObject::sysFieldToMethodCase($fieldName).$last4;
if (method_exists($this, $personalMethodName))
{
return $this->$personalMethodName(...array_slice($arguments, 1));
}
// hard field check
$this->entity->getField($fieldName);
}
// check if field exists
if ($this->_entity->hasField($fieldName))
{
return $this->sysGetList($fieldName);
}
}
$last10 = substr($name, -10);
if ($first3 == 'get' && $last10 == 'Collection')
{
$fieldName = EntityObject::sysMethodToFieldCase(substr($name, 3, -10));
if ($fieldName == '')
{
$fieldName = StringHelper::strtoupper($arguments[0]);
// check if custom method exists
$personalMethodName = $first3.EntityObject::sysFieldToMethodCase($fieldName).$last10;
if (method_exists($this, $personalMethodName))
{
return $this->$personalMethodName(...array_slice($arguments, 1));
}
// hard field check
$this->entity->getField($fieldName);
}
// check if field exists
if ($this->_entity->hasField($fieldName) && $this->_entity->getField($fieldName) instanceof Relation)
{
return $this->sysGetCollection($fieldName);
}
}
$first4 = substr($name, 0, 4);
// filler
if ($first4 == 'fill')
{
$fieldName = EntityObject::sysMethodToFieldCase(substr($name, 4));
// check if field exists
if ($this->_entity->hasField($fieldName))
{
return $this->fill([$fieldName]);
}
}
throw new SystemException(sprintf(
'Unknown method `%s` for object `%s`', $name, get_called_class()
));
}