Как получить доступ к классу при работе со свойствами инфоблока в Bitrix?
Я хотел написать класс для упрощенной работы с свойствами инфоблока...
<?php
namespace Infoblock\Property;
class Property{
private $arItem;
function __construct($setArItem) {
$this->arItem = $setArItem;
}
function getImgURL($nameImg){
$dataImageInProperty = CFile::GetFileArray($this->arItem[$nameImg]['VALUE']);
return $dataImageInProperty['SRC'];
}
}
?>
В результате получил данную ошибку:
Undefined type 'Infoblock\Property\CFile'
Подскажите пожалуйста, как получить доступ к классу CFile?
Ответы (1 шт):
Автор решения: Mihanik71
→ Ссылка
Необходимо указать правильный неймспейс для класса CFile.
1 вариант
<?php
namespace Infoblock\Property;
use \CFile;
class Property{
private $arItem;
function __construct($setArItem) {
$this->arItem = $setArItem;
}
function getImgURL($nameImg){
$dataImageInProperty = CFile::GetFileArray($this->arItem[$nameImg]['VALUE']);
return $dataImageInProperty['SRC'];
}
}
?>
Второй
<?php
namespace Infoblock\Property;
class Property{
private $arItem;
function __construct($setArItem) {
$this->arItem = $setArItem;
}
function getImgURL($nameImg){
$dataImageInProperty = \CFile::GetFileArray($this->arItem[$nameImg]['VALUE']);
return $dataImageInProperty['SRC'];
}
}
?>