Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/framework/Webapi/Validator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/framework/Webapi/Validator/EntityArrayValidator.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\Framework\Webapi\Validator;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Exception\InvalidArgumentException;
use Magento\Framework\Webapi\Validator\IOLimit\IOLimitConfigProvider;
use Magento\Framework\Exception\RuntimeException;
use Magento\Framework\Webapi\Validator\EntityArrayValidator\InputArraySizeLimitValue;

/**
 * Validates service input
 */
class EntityArrayValidator implements ServiceInputValidatorInterface
{
    /**
     * @var int
     */
    private int $complexArrayItemLimit;

    /**
     * @var IOLimitConfigProvider
     */
    private $configProvider;

    /**
     * @var InputArraySizeLimitValue
     */
    private $inputArraySizeLimitValue;

    /**
     * @param int $complexArrayItemLimit
     * @param IOLimitConfigProvider|null $configProvider
     * @param InputArraySizeLimitValue|null $inputArraySizeLimitValue
     */
    public function __construct(
        int $complexArrayItemLimit,
        ?IOLimitConfigProvider $configProvider = null,
        ?InputArraySizeLimitValue $inputArraySizeLimitValue = null
    ) {
        $this->complexArrayItemLimit = $complexArrayItemLimit;
        $this->configProvider = $configProvider ?? ObjectManager::getInstance()->get(IOLimitConfigProvider::class);
        $this->inputArraySizeLimitValue = $inputArraySizeLimitValue ?? ObjectManager::getInstance()
                ->get(InputArraySizeLimitValue::class);
    }

    /**
     * @inheritDoc
     *
     * @throws FileSystemException|RuntimeException
     */
    public function validateComplexArrayType(string $className, array $items): void
    {
        if (!$this->configProvider->isInputLimitingEnabled()) {
            return;
        }

        $maxLimit = $this->inputArraySizeLimitValue->get()
            ?? ($this->configProvider->getComplexArrayItemLimit() ?? $this->complexArrayItemLimit);

        if (count($items) > $maxLimit) {
            throw new InvalidArgumentException(
                __(
                    'Maximum items of type "%type" is %max',
                    ['type' => $className, 'max' => $maxLimit]
                )
            );
        }
    }

    /**
     * @inheritDoc
     * phpcs:disable Magento2.CodeAnalysis.EmptyBlock
     */
    public function validateEntityValue(object $entity, string $propertyName, $value): void
    {
    }
}

Spamworldpro Mini