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/rest/entity/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sale/lib/rest/entity/basketproperties.php
<?php

namespace Bitrix\Sale\Rest\Entity;

use Bitrix\Main\Error;
use Bitrix\Sale\Rest\Attributes;
use Bitrix\Sale\Result;

class BasketProperties extends Base
{
	public function getFields()
	{
		return [
			'ID' => [
				'TYPE' => self::TYPE_INT,
				'ATTRIBUTES' => [
					Attributes::ReadOnly,
				],
			],
			'BASKET_ID' => [
				'TYPE' => self::TYPE_INT,
				'ATTRIBUTES' => [
					Attributes::Required,
					Attributes::Immutable,
				],
			],
			'NAME' => [
				'TYPE' => self::TYPE_STRING,
				'ATTRIBUTES' => [
					Attributes::Required,
				],
			],
			'VALUE' => [
				'TYPE' => self::TYPE_STRING,
				'ATTRIBUTES' => [
					Attributes::Required,
				],
			],
			'CODE' => [
				'TYPE' => self::TYPE_STRING,
				'ATTRIBUTES' => [
					Attributes::Required,
				],
			],
			'SORT' => [
				'TYPE' => self::TYPE_INT,
			],
			'XML_ID' => [
				'TYPE' => self::TYPE_STRING,
			],
		];
	}

	public function internalizeFieldsModify($fields, $fieldsInfo=[])
	{
		$result = [];

		$fieldsInfo = empty($fieldsInfo) ? $this->getFields() : $fieldsInfo;
		$listFieldsInfoAdd = $this->getListFieldInfo(
			$fieldsInfo,
			[
				'filter' => [
					'ignoredAttributes' => [
						Attributes::Hidden,
						Attributes::ReadOnly,
					],
				],
			]
		);
		$listFieldsInfoUpdate = $this->getListFieldInfo(
			$fieldsInfo,
			[
				'filter' => [
					'ignoredAttributes' => [
						Attributes::Hidden,
						Attributes::ReadOnly,
						Attributes::Immutable,
					],
					'skipFields' => [
						'ID',
					],
				],
			]
		);

		foreach ($fields['BASKET_ITEM']['PROPERTIES'] as $k => $item)
		{
			$result['BASKET_ITEM']['PROPERTIES'][$k] = $this->internalizeFields(
				$item,
				$this->isNewItem($item) ? $listFieldsInfoAdd : $listFieldsInfoUpdate
			);
		}

		return $result;
	}

	public function checkFieldsModify($fields)
	{
		$result = new Result();

		$emptyFields = [];

		if (!isset($fields['BASKET_ITEM']['ID']))
		{
			$emptyFields[] = '[basketItem][id]';
		}
		if (!isset($fields['BASKET_ITEM']['PROPERTIES']) || !is_array($fields['BASKET_ITEM']['PROPERTIES']))
		{
			$emptyFields[] = '[basketItem][properties][]';
		}

		if (!empty($emptyFields))
		{
			$result->addError(new Error(implode(', ', $emptyFields)));
		}
		else
		{
			$result = parent::checkFieldsModify($fields);
		}

		return $result;
	}

	public function checkRequiredFieldsModify($fields)
	{
		$result = new Result();

		$listFieldsInfoAdd = $this->getListFieldInfo(
			$this->getFields(),
			[
				'filter' => [
					'ignoredAttributes' => [
						Attributes::Hidden,
						Attributes::ReadOnly,
					],
				],
			]
		);
		$listFieldsInfoUpdate = $this->getListFieldInfo(
			$this->getFields(),
			[
				'filter' => [
					'ignoredAttributes' => [
						Attributes::Hidden,
						Attributes::ReadOnly,
						Attributes::Immutable,
					],
				],
			]
		);

		foreach ($fields['BASKET_ITEM']['PROPERTIES'] as $k => $item)
		{
			$required = $this->checkRequiredFields(
				$item,
				$this->isNewItem($item) ? $listFieldsInfoAdd : $listFieldsInfoUpdate
			);
			if (!$required->isSuccess())
			{
				$result->addError(new Error(
					'[properties][' . $k . '] - '
						. implode(', ', $required->getErrorMessages())
						. '.'
				));
			}
		}

		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit