Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
storedocumentspecifictable.php
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Type
;
4
5
use
Bitrix\Catalog\StoreDocumentTable
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\NotImplementedException
;
9
use
Bitrix\Main\ORM\Data\DeleteResult
;
10
use
Bitrix\Main\ORM\Data\UpdateResult
;
11
12
/*
13
* This class' children are meant to be used to work with a specific document type.
14
* Each document type has its own user fields set, so they need to have their own separate ORM classes.
15
* If you need to select all documents/a set of documents regardless of their type,
16
* use \Bitrix\Catalog\StoreDocumentTable; however, do note that it doesn't support user fields.
17
*/
18
abstract
class
StoreDocumentSpecificTable
extends
StoreDocumentTable
19
{
20
abstract
public
static
function
getType
(): string;
21
22
public
static
function
getUfId
()
23
{
24
return
'CAT_STORE_DOCUMENT_'
. static::getType();
25
}
26
27
public
static
function
setDefaultScope
($query)
28
{
29
$query->where(
'DOC_TYPE'
, static::getType());
30
}
31
32
public
static
function
add
(array $data)
33
{
34
$data[
'DOC_TYPE'
] = static::getType();
35
return
parent::add($data);
36
}
37
38
public
static
function
update
($primary, array $data)
39
{
40
$result =
new
UpdateResult
();
41
42
$documentType =
self::getByPrimary
($primary, [
'select'
=> [
'DOC_TYPE'
]])->fetch();
43
if
(!$documentType)
44
{
45
$result->addError(
new
Error
(
Loc::getMessage
(
'STORE_DOCUMENT_SPECIFIC_TABLE_DOC_NOT_FOUND_ERROR'
)));
46
47
return
$result;
48
}
49
50
if
($documentType[
'DOC_TYPE'
] !== static::getType())
51
{
52
$result->addError(
new
Error
(
Loc::getMessage
(
'STORE_DOCUMENT_SPECIFIC_TABLE_WRONG_DOC_TYPE_ERROR'
)));
53
54
return
$result;
55
}
56
57
if
(isset($data[
'DOC_TYPE'
]))
58
{
59
unset($data[
'DOC_TYPE'
]);
60
}
61
62
return
parent::update($primary, $data);
63
}
64
65
public
static
function
delete
($primary)
66
{
67
$result =
new
DeleteResult
();
68
69
$documentType =
self::getByPrimary
($primary, [
'select'
=> [
'DOC_TYPE'
]])->fetch();
70
if
(!$documentType)
71
{
72
$result->addError(
new
Error
(
Loc::getMessage
(
'STORE_DOCUMENT_SPECIFIC_TABLE_DOC_NOT_FOUND_ERROR'
)));
73
74
return
$result;
75
}
76
77
if
($documentType[
'DOC_TYPE'
] !== static::getType())
78
{
79
$result->addError(
new
Error
(
Loc::getMessage
(
'STORE_DOCUMENT_SPECIFIC_TABLE_WRONG_DOC_TYPE_ERROR'
)));
80
81
return
$result;
82
}
83
84
return
parent::delete($primary);
85
}
86
}
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable
Definition
storedocumentspecifictable.php:19
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable\setDefaultScope
static setDefaultScope($query)
Definition
storedocumentspecifictable.php:27
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable\getUfId
static getUfId()
Definition
storedocumentspecifictable.php:22
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable\getType
static getType()
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable\add
static add(array $data)
Definition
storedocumentspecifictable.php:32
Bitrix\Catalog\Document\Type\StoreDocumentSpecificTable\update
static update($primary, array $data)
Definition
storedocumentspecifictable.php:38
Bitrix\Catalog\StoreDocumentTable
Definition
storedocumenttable.php:65
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\NotImplementedException
Definition
exception.php:147
Bitrix\Main\ORM\Data\DataManager\getByPrimary
static getByPrimary($primary, array $parameters=array())
Definition
datamanager.php:343
Bitrix\Main\ORM\Data\DeleteResult
Definition
deleteresult.php:12
Bitrix\Main\ORM\Data\UpdateResult
Definition
updateresult.php:14
Bitrix\Catalog\Document\Type
Definition
storedocumentarrivaltable.php:3
modules
catalog
lib
document
type
storedocumentspecifictable.php
Создано системой
1.10.0