Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
SmartTracking.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Result
;
7
use
Bitrix\Socialnetwork\Space\Toolbar\Switcher\AbstractSwitcher
;
8
use CSocNetLogFollow;
9
10
class
SmartTracking
extends
AbstractSwitcher
11
{
12
public
const
COMMON_LIVEFEED
=
'**'
;
13
14
public
function
enable
():
Result
15
{
16
$result =
new
Result
();
17
if
($this->
isEnabled
())
18
{
19
return
$result;
20
}
21
22
if
(!CSocNetLogFollow::Set($this->userId, $this->code, static::TYPE_OFF))
23
{
24
$result->addError(
new
Error
(
'Cannot switch type'
));
25
}
26
27
$this->
invalidate
();
28
29
return
$result;
30
}
31
32
public
function
disable
():
Result
33
{
34
$result =
new
Result
();
35
if
(!$this->
isEnabled
())
36
{
37
return
$result;
38
}
39
40
if
(!CSocNetLogFollow::Set($this->userId, $this->code, static::TYPE_ON))
41
{
42
$result->addError(
new
Error
(
'Cannot switch type'
));
43
}
44
45
$this->
invalidate
();
46
47
return
$result;
48
}
49
50
public
function
getValue
(): string
51
{
52
if
($this->isInitialized)
53
{
54
return
$this->value
;
55
}
56
57
$this->value = CSocNetLogFollow::GetDefaultValue($this->userId);
58
$this->isInitialized =
true
;
59
60
return
$this->value
;
61
}
62
63
public
function
isEnabled
(): bool
64
{
65
return
$this->
getValue
() === static::TYPE_OFF;
66
}
67
68
public
static
function
getDefaultCode
(): string
69
{
70
return
static::COMMON_LIVEFEED;
71
}
72
73
protected
function
canSwitch
(): bool
74
{
75
return
true
;
76
}
77
}
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Socialnetwork\Space\Toolbar\Switcher\AbstractSwitcher
Definition
AbstractSwitcher.php:12
Bitrix\Socialnetwork\Space\Toolbar\Switcher\AbstractSwitcher\$value
string $value
Definition
AbstractSwitcher.php:20
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking
Definition
SmartTracking.php:11
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\canSwitch
canSwitch()
Definition
SmartTracking.php:73
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\COMMON_LIVEFEED
const COMMON_LIVEFEED
Definition
SmartTracking.php:12
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\getDefaultCode
static getDefaultCode()
Definition
SmartTracking.php:68
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\disable
disable()
Definition
SmartTracking.php:32
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\enable
enable()
Definition
SmartTracking.php:14
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\getValue
getValue()
Definition
SmartTracking.php:50
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode\SmartTracking\isEnabled
isEnabled()
Definition
SmartTracking.php:63
Bitrix\Socialnetwork\Space\Toolbar\Switcher\Mode
Definition
SmartTracking.php:3
Bitrix\Socialnetwork\Space\Toolbar\Switcher\invalidate
invalidate()
Definition
CacheTrait.php:32
modules
socialnetwork
lib
Space
Toolbar
Switcher
Mode
SmartTracking.php
Создано системой
1.10.0