Documentation

Custom controller

Standard iblock REST controller \Bitrix\Iblock\Controller\DefaultElement includes the following methods:

MethodDescription
getElementEntityAllowedListAllowed iblock entity fields \Bitrix\Iblock\ElementTable::getMap. They are selected by default, when the query doesn't contain select.
getAllowedListList of fields permitted for selection. Default permitted iblock fields from the method getElementEntityAllowedList and all iblock properties. If you want to use other fields and specifically, associations, list all the IDs here.
getActionRetrieves a single element by ID.
listActionSelects several elements.

Both creating a complete custom and inheriting from standard controller with redefining necessary methods are permitted.

After describing your own custom controller, you must register it in Service Locator Service Locator - is a design pattern for convenient handling of application services.

Find more details in the Bitrix Framework learning course.
with the identifier iblock.element.{IBLOCK_API_CODE}.rest.controller, where {IBLOCK_API_CODE} - is API character code value (API_CODE) for your iblock. For example: iblock.element.OfficialNews.rest.controller.

By default, controllers operate only within REST context. Starting from version 20.100.200, public unlimited access to iblock data is available via AJAX-controller mechanism. All prefilters must be cleared:

class MyElement extends \Bitrix\Iblock\Controller\DefaultElement
{
    protected function getDefaultPreFilters()
    {
        return [];
    }
}

© «Bitrix24», 2001-2024