Skip to content

Commit d2a2bd1

Browse files
feat: Поддержка множественных свойств инфоблоков
1 parent 20ff23b commit d2a2bd1

6 files changed

Lines changed: 93 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
2.3.0
5+
-----
6+
7+
### Добавлено:
8+
9+
- Поддержка множественных свойств инфоблоков при помощи `DynamicMultiplePropertiesTable`
10+
411
2.2.1
512
-----
613

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
`getIblockId()`;
3737
- при объявлении `Bitrix\Main\Entity\ReferenceField` (или `Bitrix\Main\ORM\Fields\Relations\Reference`)
3838
воспользоваться созданным классом;
39-
39+
4040
```php
4141
use Bitrix\Iblock\ElementTable;
4242
use Bitrix\Main\Entity\ReferenceField;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/** @noinspection PhpMissingReturnTypeInspection */
4+
5+
namespace WebArch\BitrixOrmTools\Iblock\Property;
6+
7+
use Bitrix\Main\ORM\Data\DataManager;
8+
use Bitrix\Main\ORM\Fields\Field;
9+
use Bitrix\Main\ORM\Fields\IntegerField;
10+
use Bitrix\Main\ORM\Fields\StringField;
11+
use Bitrix\Main\ORM\Fields\TextField;
12+
13+
abstract class DynamicMultiplePropertiesTable extends DataManager
14+
{
15+
protected const TABLE_PREFIX = 'b_iblock_element_prop_m';
16+
17+
/**
18+
* Возвращает id инфоблока.
19+
*
20+
* @return int
21+
*/
22+
abstract public static function getIblockId(): int;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public static function getTableName()
28+
{
29+
return self::TABLE_PREFIX . static::getIblockId();
30+
}
31+
32+
/**
33+
* @inheritDoc
34+
* @return array<string, Field>
35+
*/
36+
public static function getMap()
37+
{
38+
return [
39+
'ID' => (new IntegerField('ID'))->configurePrimary(true)
40+
->configureAutocomplete(true)
41+
->configureRequired(false),
42+
'IBLOCK_ELEMENT_ID' => (new IntegerField('IBLOCK_ELEMENT_ID'))->configureRequired(true),
43+
'IBLOCK_PROPERTY_ID' => (new IntegerField('IBLOCK_PROPERTY_ID'))->configureRequired(true),
44+
'VALUE' => (new TextField('VALUE'))->configureRequired(true),
45+
'VALUE_ENUM' => (new IntegerField('VALUE_ENUM')),
46+
'VALUE_NUM' => (new IntegerField('VALUE_NUM')),
47+
'DESCRIPTION' => (new StringField('DESCRIPTION'))->configureSize(255),
48+
];
49+
}
50+
}

src/main/Iblock/Property/DynamicSinglePropertiesTable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
/** @noinspection PhpMissingReturnTypeInspection */
4+
35
namespace WebArch\BitrixOrmTools\Iblock\Property;
46

57
use Bitrix\Iblock\PropertyTable;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace WebArch\BitrixOrmTools\Test\Fixture;
4+
5+
use WebArch\BitrixOrmTools\Iblock\Property\DynamicMultiplePropertiesTable;
6+
7+
class DynamicMultiplePropertiesTableFixture extends DynamicMultiplePropertiesTable
8+
{
9+
/**
10+
* @inheritDoc
11+
*/
12+
public static function getIblockId(): int
13+
{
14+
return 0;
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace WebArch\BitrixOrmTools\Test\Fixture;
4+
5+
use WebArch\BitrixOrmTools\Iblock\Property\DynamicSinglePropertiesTable;
6+
7+
class DynamicSinglePropertiesTableFixture extends DynamicSinglePropertiesTable
8+
{
9+
/**
10+
* @inheritDoc
11+
*/
12+
public static function getIblockId(): int
13+
{
14+
return 0;
15+
}
16+
}
17+

0 commit comments

Comments
 (0)