Skip to content

Commit b3d58e8

Browse files
authored
Create CourseSiteTable.php
1 parent d04c7e6 commit b3d58e8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

lib/CourseSiteTable.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
class CourseSiteTable extends Entity\DataManager
6+
{
7+
/**
8+
* Returns DB table name for entity.
9+
*
10+
* @return string
11+
*/
12+
public static function getTableName()
13+
{
14+
return 'b_learn_course_site';
15+
}
16+
17+
/**
18+
* Returns entity map definition.
19+
*
20+
* @return array
21+
*/
22+
public static function getMap()
23+
{
24+
return array(
25+
new Entity\IntegerField('COURSE_ID', array(
26+
'required' => true,
27+
'primary' => true
28+
)),
29+
new Entity\ReferenceField(
30+
'COURSE',
31+
'\Learning\CourseTable',
32+
array('=this.COURSE_ID' => 'ref.ID'),
33+
array('join_type' => 'LEFT')
34+
),
35+
new Entity\StringField('SITE_ID', array(
36+
'primary' => true,
37+
'validation' => array(__CLASS__, 'validateSiteId'),
38+
)),
39+
new Entity\ReferenceField(
40+
'SITE',
41+
'\Bitrix\Main\SiteTable',
42+
array('=this.SITE_ID' => 'ref.LID'),
43+
array('join_type' => 'LEFT')
44+
),
45+
);
46+
}
47+
/**
48+
* Returns validators for SITE_ID field.
49+
*
50+
* @return array
51+
*/
52+
public static function validateSiteId()
53+
{
54+
return array(
55+
new Main\Entity\Validator\Length(null, 2),
56+
);
57+
}
58+
}

0 commit comments

Comments
 (0)