Last Modified: 31.03.2022
Majority of Object and Collection methods are virtual, processed via magic __call. At the same time, they are created for intuitively clear and self-explanatory named methods; without IDE autocomplete their significance substantially falls.
We have created a special service file with annotation for all entities for IDE to be aware that these methods exist, helping to navigate in the large number of classes and methods.
Starting from the Main version 20.100.0, file with ORM kernel class annotations is included into distribution package and located at
The cli-command orm:annotate is used for generating such annotations:
$ cd bitrix
$ php bitrix.php orm:annotate
Modules are scanned during command execution and specifically all files from folders bitrix/modules/[module]/lib. When file detects an entity "mapping" (class Table, subclass
Bitrix\Main\ORM\Data\DataManager), its map is analyzed (list of fields).
Command result contains the file (by default
bitrix/modules/orm_annotations.php), containing description of entity Object and Collection classes. It also declares Table class duplicate and several actually non-existent helper classes, assisting in IDE autocomplete from the moment of query to the use of resulting objects.
By default, scans only the Main module. Scanning random modules can be set directly:
// annotating entities for arbitrary module:
$ php bitrix.php orm:annotate -m tasks
// annotating several modules:
$ php bitrix.php orm:annotate -m main,intranet,faceid
// annotating all modules:
$ php bitrix.php orm:annotate -m all
In the nearest future we plan to introduce monitoring for all known entities in the development mode, to be able to call annotations automatically when updating the fields. Then, console won't have to be used as much often.
Partially, it's convenient to selectively replace classes on re-generation. When annotations already have the described modules, repeat annotation for one of them will update description only one of its classes and other won't be deleted. Use the parameter -c for the reset:
$ php bitrix.php orm:annotate -c -m all
To view all available command parameters, execute the command:
$ php bitrix.php help orm:annotate