Skip to content

Commit b433484

Browse files
authored
Create RightsTable.php
1 parent a04f5f2 commit b433484

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

lib/RightsTable.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
/**
6+
* Class RightsTable
7+
*
8+
* Fields:
9+
* <ul>
10+
* <li> LESSON_ID int mandatory
11+
* <li> SUBJECT_ID string(100) mandatory
12+
* <li> TASK_ID int mandatory
13+
* </ul>
14+
*
15+
* @package Learning
16+
**/
17+
18+
class RightsTable extends Entity\DataManager
19+
{
20+
/**
21+
* Returns DB table name for entity.
22+
*
23+
* @return string
24+
*/
25+
public static function getTableName()
26+
{
27+
return 'b_learn_rights';
28+
}
29+
30+
/**
31+
* Returns entity map definition.
32+
*
33+
* @return array
34+
*/
35+
public static function getMap()
36+
{
37+
return array(
38+
'LESSON_ID' => new Entity\IntegerField('LESSON_ID', array(
39+
'primary' => true,
40+
'autocomplete' => true,
41+
)),
42+
'LESSON' => new Entity\ReferenceField(
43+
'LESSON',
44+
'\Learning\LessonTable',
45+
array('=this.LESSON_ID' => 'ref.ID'),
46+
array('join_type' => 'LEFT')
47+
),
48+
'SUBJECT_ID' => new Entity\StringField('SUBJECT_ID', array(
49+
'primary' => true,
50+
'validation' => array(__CLASS__, 'validateSubjectId'),
51+
)),
52+
'TASK_ID' => new Entity\IntegerField('TASK_ID', array(
53+
'required' => true
54+
)),
55+
'TASK' => new Entity\ReferenceField(
56+
'TASK',
57+
'Bitrix\Main\TaskTable',
58+
array('=this.TASK_ID' => 'ref.ID'),
59+
array('join_type' => 'LEFT')
60+
)
61+
);
62+
}
63+
/**
64+
* Returns validators for SUBJECT_ID field.
65+
*
66+
* @return array
67+
*/
68+
public static function validateSubjectId()
69+
{
70+
return array(
71+
new Entity\Validator\Length(null, 100)
72+
);
73+
}
74+
}
75+

0 commit comments

Comments
 (0)