Views: 3257
Last Modified: 30.03.2022

When you already have available records, you don't have to retrieve them from database again. Object can be restored having primary key values as a minimum:

$book = \Bitrix\Main\Test\Typography\Book::wakeUp(1);

You may indicate not only the primary key, but also partial or full set of data:

$book = \Bitrix\Main\Test\Typography\Book::wakeUp(['ID' => 1, 'TITLE' => 'Title 1', 'PUBLISHER_ID' => 253]);

Similar to creating objects, the method is applicable for EO_ classes as well, for calling directly from entity:

// your class
$book = \Bitrix\Main\Test\Typography\Book::wakeUp(
	['ID' => 1, 'TITLE' => 'Title 1']
);

// system class
$book = \Bitrix\Main\Test\Typography\EO_Book::wakeUp(
	['ID' => 1, 'TITLE' => 'Title 1']
);

// using the entity factory
$book = \Bitrix\Main\Test\Typography\BookTable::wakeUpObject(
	['ID' => 1, 'TITLE' => 'Title 1']
);

You can pass not only scalar values in wakeUp, but also values of Relations:

$book = \Bitrix\Main\Test\Typography\Book::wakeUp([
	'ID' => 2,
	'TITLE' => 'Title 2',
	'PUBLISHER' => ['ID' => 253, 'TITLE' => 'Publisher Title 253'],
	'AUTHORS' => [
		['ID' => 17, 'NAME' => 'Name 17'],
		['ID' => 18, 'NAME' => 'Name 18']
	]
]);




Courses developed by Bitrix24