0
0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2024-12-28 14:58:08 +00:00
salesagility_SuiteCRM/Api/V8/Param/PageParams.php
2023-07-18 15:53:08 +01:00

47 lines
1.2 KiB
PHP

<?php
namespace Api\V8\Param;
use Api\V8\BeanDecorator\BeanManager;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
#[\AllowDynamicProperties]
class PageParams extends BaseParam
{
/**
* @return integer
*/
public function getSize()
{
return isset($this->parameters['size']) ? (int)$this->parameters['size'] : BeanManager::DEFAULT_ALL_RECORDS;
}
/**
* @return integer
*/
public function getNumber()
{
return isset($this->parameters['number']) ? (int)$this->parameters['number'] : BeanManager::DEFAULT_OFFSET;
}
/**
* @inheritdoc
*/
protected function configureParameters(OptionsResolver $resolver)
{
$resolver
->setDefined('size')
->setAllowedTypes('size', 'string')
->setAllowedValues('size', $this->validatorFactory->createClosure([
new Assert\GreaterThan(0),
]));
$resolver
->setDefined('number')
->setAllowedTypes('number', 'string')
->setAllowedValues('number', $this->validatorFactory->createClosure([
new Assert\GreaterThan(0),
]));
}
}