Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
formresponse.php
1
<?php
2
3
namespace
Bitrix\Seo\LeadAds\Response
;
4
5
6
use
Bitrix\Main\Result
;
7
use
Bitrix\Seo\LeadAds\LeadAdsForm
;
8
use
Bitrix\Seo\Retargeting\Response
;
9
use
Bitrix\Seo\LeadAds\Response\Builder\FormBuilderInterface
;
10
11
class
FormResponse
extends
Result
12
{
14
protected
$data
= [];
15
17
protected
$formBuilder
;
18
20
private
$currentResponse;
21
23
private
$responseCount;
24
29
public
function
__construct
(
FormBuilderInterface
$formBuilder
,
Response
... $responses)
30
{
31
parent::__construct();
32
33
$this->formBuilder =
$formBuilder
;
34
$this->currentResponse = 0;
35
$this->responseCount = count($responses);
36
37
foreach
($responses as $response)
38
{
39
if
(!$response->isSuccess())
40
{
41
$this->
addErrors
($response->getErrors());
42
}
43
}
44
45
$this->data = array_values($responses);
46
}
47
54
public
function
setData
(array
$data
):
FormResponse
55
{
56
return
new
static
(
$this->formBuilder
,...$data);
57
}
58
62
public
function
fetch(): ?
LeadAdsForm
63
{
64
if
($this->currentResponse >= $this->responseCount || !$this->
isSuccess
())
65
{
66
return
null
;
67
}
68
70
if
(!$form = $this->data[$this->currentResponse]->fetch())
71
{
72
++$this->currentResponse;
73
74
return
$this->fetch();
75
}
76
77
return
$this->formBuilder->buildForm($form);
78
}
79
83
public
function
fetchAll
(): array
84
{
85
for
($fetchResult = array();
null
!== $item = $this->fetch();)
86
{
87
$fetchResult[] = $item;
88
}
89
90
return
$fetchResult;
91
}
92
}
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Response
Definition
response.php:5
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Main\Result\addErrors
addErrors(array $errors)
Definition
result.php:98
Bitrix\Main\Result\isSuccess
isSuccess()
Definition
result.php:39
Bitrix\Seo\LeadAds\LeadAdsForm
Definition
leadadsform.php:9
Bitrix\Seo\LeadAds\Response\FormResponse
Definition
formresponse.php:12
Bitrix\Seo\LeadAds\Response\FormResponse\$formBuilder
$formBuilder
Definition
formresponse.php:17
Bitrix\Seo\LeadAds\Response\FormResponse\$data
$data
Definition
formresponse.php:14
Bitrix\Seo\LeadAds\Response\FormResponse\setData
setData(array $data)
Definition
formresponse.php:54
Bitrix\Seo\LeadAds\Response\FormResponse\__construct
__construct(FormBuilderInterface $formBuilder, Response... $responses)
Definition
formresponse.php:29
Bitrix\Seo\LeadAds\Response\FormResponse\fetchAll
fetchAll()
Definition
formresponse.php:83
Bitrix\Seo\Retargeting\Response
Definition
response.php:8
Bitrix\Seo\LeadAds\Response\Builder\FormBuilderInterface
Definition
formbuilderinterface.php:8
Bitrix\Seo\LeadAds\Response
modules
seo
lib
leadads
response
formresponse.php
Создано системой
1.10.0