A
A
alisiy2019-09-27 20:38:26
1C-Bitrix
alisiy, 2019-09-27 20:38:26

How to create a D7 entity?

I do everything as described here: https://dev.1c-bitrix.ru/learning/course/index.php...
But when I try to use the class, I get Class not found.
I read this topic - https://dev.1c-bitrix.ru/support/forum/forum6/topi...
I did not understand the following - why should I connect the module if the lesson clearly says:


It remains only to fix the entity code in the project. According to the general rules for naming files in D7, the entity code must be saved in the file: local/modules/somepartner.mybookscatalog/lib/book.php
After that, the system will automatically include the file when it finds calls to the BookTable class.

So after I just place the code in the class file, or do I still need to include the module?
I include the module - \Bitrix\Main\Loader::includeModule('my.foo') - returns false. Why? Created file local/modules/my.foo/include.php - still returns false.
How should it work? Why is there nothing about this in the lesson?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2019-09-27
@alisiy

Entity D7 is a regular class. In order for everything to work, you need to connect this class.
If the class is outside the module, then through autoload or the usual include (or require).
You seem to have a module. In order for everything to work, the module must have at least the required files and be installed through the system menu. It is installed , and not just copied to the modules folder.
Next, the class that describes your table in the database must be placed in the lib folder of the module. The file name must be in lowercase and must not contain the word Table.
For example, for the BooksTable class, the file name should be books.php

T
Trionik, 2021-03-12
@Trionik

Entity D7 is a regular class.

Judging from what is written in Bitrix https://dev.1c-bitrix.ru/learning/course/index.php...
Entity is a table, specifically in Bitrix implemented as a class, if there is a need to dynamically create a table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question