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/sale/lib/basket/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sale/lib/basket/singlerefreshstrategy.php
<?php

namespace Bitrix\Sale\Basket;

use Bitrix\Main\ArgumentNullException;
use Bitrix\Main\ObjectNotFoundException;
use Bitrix\Sale\BasketBase;

class SingleRefreshStrategy extends RefreshStrategy
{
	public function __construct(array $data = null)
	{
		parent::__construct($data);

		if (empty($this->data['BASKET_ITEM']) && empty($this->data['BASKET_ITEM_CODE']))
		{
			throw new ArgumentNullException('Parameters "BASKET_ITEM" or "BASKET_ITEM_CODE" should not be empty.');
		}
	}

	protected function extractItem(BasketBase $basket)
	{
		$basketItem = null;

		if (isset($this->data['BASKET_ITEM']) && $this->data['BASKET_ITEM'] instanceof BasketItem)
		{
			$basketItem = $this->data['BASKET_ITEM'];
		}
		elseif (!empty($this->data['BASKET_ITEM_CODE']))
		{
			$basketItem = $basket->getItemByBasketCode($this->data['BASKET_ITEM_CODE']);
		}

		return $basketItem;
	}

	protected function getItemToRefresh(BasketBase $basket)
	{
		$basketItem = $this->extractItem($basket);
		if ($basketItem === null)
		{
			throw new ObjectNotFoundException('Entity "BasketItem" not found');
		}

		$basketRefreshStart = time();
		$refreshGap = $this->getBasketRefreshGapTime();

		$basketItemLastRefresh = $this->getBasketItemRefreshTimestamp($basketItem);
		if ($basketRefreshStart - $basketItemLastRefresh >= $refreshGap)
		{
			return $basketItem;
		}

		return null;
	}

	protected function getProductData(BasketBase $basket)
	{
		$itemToRefresh = $this->getItemToRefresh($basket);

		$items = array();
		if (!empty($itemToRefresh))
		{
			$items[] = $itemToRefresh;
		}

		return $this->getProviderResult($basket, $items);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit