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/cvetdv.ru/bitrix/modules/yandex.market/lib/catalog/segment/offer/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/yandex.market/lib/catalog/segment/offer/factory.php
<?php
namespace Yandex\Market\Catalog\Segment\Offer;

use Yandex\Market\Catalog\Endpoint;
use Yandex\Market\Catalog\Segment;
use Yandex\Market\Export\Param\TagBundle;
use Yandex\Market\Trading\Business;
use Yandex\Market\Trading\Campaign;

class Factory implements Segment\Factory
{
	public function businessConfig(Business\Model $business)
	{
		return new Segment\BusinessConfig(new BusinessFormat());
	}

	public function campaignConfigs(Business\Model $business)
	{
        $result = [];

        /** @var Campaign\Model $campaign */
        foreach ($business->getCampaignCollection() as $campaign)
        {
            $result[] = new Segment\CampaignConfig(new CampaignFormat(), $campaign->getId(), $campaign->getName(), $campaign->getPlacement());
        }

        return $result;
	}

	public function endpoints(Business\Model $business, Segment\Collection $segmentCollection)
	{
		return array_filter(array_merge(
            $this->offerEndpoints($business, $segmentCollection->getBusinessItem()),
            $this->termsEndpoints($business, $segmentCollection)
        ));
	}

    private function offerEndpoints(Business\Model $business, Segment\Model $businessSegment = null)
    {
        if ($businessSegment === null) { return []; }

        $termsTags = $this->termsTags();
        $map = $businessSegment->getParamCollection()->getTagMap()->cloneWithout($termsTags);

        if ($map->isEmpty()) { return []; }

        $format = (new BusinessFormat())->getTag()->cloneWithout($termsTags);

        return [
            new Endpoint\Endpoint(
                new Endpoint\Offer($business->getId()),
                new TagBundle($format, $map)
            ),
        ];
    }

    private function termsEndpoints(Business\Model $business, Segment\Collection $segmentCollection)
    {
        $result = [];
        $termsTags = $this->termsTags();
        $businessSegment = $segmentCollection->getBusinessItem();
        $commonMap = $businessSegment !== null
            ? $businessSegment->getParamCollection()->getTagMap()->cloneOnly($termsTags)
            : null;

        if ($commonMap !== null && !$commonMap->isEmpty())
        {
	        /** @var Campaign\Model $campaign */
            foreach ($business->getCampaignCollection() as $campaign)
            {
                $campaignSegment = $segmentCollection->getCampaignItem($campaign->getId());
				$campaignMap = $campaignSegment !== null
                    ? $campaignSegment->getParamCollection()->getTagMap()->merge($commonMap)
                    : $commonMap;

                $result[] = new Endpoint\Endpoint(
                    new Endpoint\Terms($campaign->getId()),
                    new TagBundle((new CampaignFormat())->getTag(), $campaignMap),
                    'quantum'
                );
            }
        }
        else
        {
            /** @var Segment\Model $segment */
            foreach ($segmentCollection as $segment)
            {
                if (!$segment->isCampaign()) { continue; }

                $map = $segment->getParamCollection()->getTagMap();

                if (!$map->hasAny($termsTags)) { continue; }

                $result[] = new Endpoint\Endpoint(
                    new Endpoint\Terms($segment->getCampaignId()),
                    new TagBundle((new CampaignFormat())->getTag(), $map->cloneOnly($termsTags)),
                    'quantum'
                );
            }
        }

        return $result;
    }

    private function termsTags()
    {
        return [
            'min-quantity',
            'step-quantity',
        ];
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit