Custom controller implementation
Standard iblock REST controller \Bitrix\Iblock\Controller\DefaultElement
includes the following methods:
Method | Descripton |
---|---|
getElementEntityAllowedList | Permitted iblock fields \Bitrix\Iblock\ElementTable::getMap . They are selected by default, if the query didn't indicate select . |
getAllowedList | List of permitted fields for retrieval. Iblock fields from method getElementEntityAllowedList and all iblock properties are permitted by default. If you want to use other fields and especially relations, you need to list all IDs in this parameter. |
getAction | Gets a single element by ID. |
listAction | Gets several elements. |
Allows to create a full controller, as well as inherit from standard controller with redefining necessary methods.
After describing your own controller class, register it in the
Service locator
Service locator is a design template for convenient use of app services.
Learn more here: Bitrix Framework.
with identifier iblock.element.{IBLOCK_API_CODE}.rest.controller
, where {IBLOCK_API_CODE} - API symbolic code value (API_CODE) of your iblock. For example: iblock.element.OfficialNews.rest.controller
.
By default, controller operate only within REST context. Starting from version 20.100.200, you can access public unlimited access to iblock data via AJAX-controller mechanism. To do it, you need to clear all pre-filters:
class MyElement extends \Bitrix\Iblock\Controller\DefaultElement { protected function getDefaultPreFilters() { return []; } }