Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Job.php
1<?php
2
4
5use \Bitrix\Main\Entity;
6use \Bitrix\Main\Localization\Loc;
9
10Loc::loadMessages(__FILE__);
11
12class JobTable extends Entity\DataManager
13{
14
15 public static function getTableName()
16 {
17 return 'b_seo_sitemap_job';
18 }
19
20 public static function getMap()
21 {
22 return [
23 'ID' => new Entity\IntegerField('ID', [
24 'primary' => true,
25 'autocomplete' => true,
26 'title' => 'ID',
27 ]),
28 'SITEMAP_ID' => new Entity\IntegerField('SITEMAP_ID', [
29 'required' => true,
30 'title' => 'Sitemap ID',
31 ]),
32 'RUNNING' => new Entity\BooleanField('RUNNING', [
33 'required' => true,
34 'title' => 'If job is running now',
35 'values' => ['Y', 'N'],
36 ]),
37 'STATUS' => new Entity\StringField('STATUS', [
38 'required' => true,
39 'default_value' => Job::STATUS_REGISTER,
40 'title' => 'Status of job',
41 ]),
42 'STATUS_MESSAGE' => new Entity\StringField('STATUS_MESSAGE', [
43 'title' => 'Text message of status current job',
44 ]),
45 'STEP' => new Entity\IntegerField('STEP', [
46 'required' => true,
47 'default_value' => 0,
48 'title' => 'Current step',
49 ]),
50 'STATE' => new Entity\StringField('STATE', [
51 'serialized' => true,
52 'title' => 'Process state data',
53 ]),
54 'DATE_MODIFY' => new Entity\DatetimeField('DATE_MODIFY', [
55 'title' => 'Date of changes',
56 ]),
57 ];
58 }
59
60 public static function onBeforeAdd(Entity\Event $event)
61 {
62 return self::prepareChanges($event);
63 }
64
70 public static function onBeforeUpdate(Entity\Event $event)
71 {
72 return self::prepareChanges($event);
73 }
74
75 protected static function prepareChanges(Entity\Event $event): Entity\EventResult
76 {
77 $result = new Entity\EventResult();
78 $result->modifyFields([
79 'DATE_MODIFY' => (new DateTime()),
80 ]);
81
82 return $result;
83 }
84}
static loadMessages($file)
Definition loc.php:64
static onBeforeUpdate(Entity\Event $event)
Definition Job.php:70
static onBeforeAdd(Entity\Event $event)
Definition Job.php:60
static prepareChanges(Entity\Event $event)
Definition Job.php:75
const STATUS_REGISTER
Definition Job.php:35