![]() 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/ |
<?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\Api\SearchCriteriaInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\InvalidArgumentException; use Magento\Framework\Webapi\Validator\IOLimit\IOLimitConfigProvider; /** * Validates search criteria inputs */ class SearchCriteriaValidator implements ServiceInputValidatorInterface { /** * @var int */ private $maximumPageSize; /** * @var IOLimitConfigProvider|null */ private $configProvider; /** * @param int $maximumPageSize * @param IOLimitConfigProvider|null $configProvider */ public function __construct(int $maximumPageSize, ?IOLimitConfigProvider $configProvider = null) { $this->maximumPageSize = $maximumPageSize; $this->configProvider = $configProvider ?? ObjectManager::getInstance() ->get(IOLimitConfigProvider::class); } /** * @inheritDoc * phpcs:disable Magento2.CodeAnalysis.EmptyBlock */ public function validateComplexArrayType(string $className, array $items): void { } /** * @inheritDoc */ public function validateEntityValue(object $entity, string $propertyName, $value): void { if ($entity instanceof SearchCriteriaInterface && $propertyName === 'pageSize' && $this->configProvider->isInputLimitingEnabled() && $value > ($max = $this->configProvider->getMaximumPageSize() ?? $this->maximumPageSize) ) { throw new InvalidArgumentException( __('Maximum SearchCriteria pageSize is %max', ['max' => $max]) ); } } }