|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
protected ProducerSolver $producerSolver; |
|
|
protected ProducerSolver $producerSolver; |
|
|
protected ProducerBuilder $producerBuilder; |
|
|
protected ProducerBuilder $producerBuilder; |
|
|
|
|
|
protected PageSizer $pageSizer; |
|
|
|
|
|
|
|
|
public function loadDependencies(): void |
|
|
public function loadDependencies(): void |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->pageSizer = \Yii::$app->pageSizer; |
|
|
$this->producerSolver = $this->loadService(ProducerSolver::class); |
|
|
$this->producerSolver = $this->loadService(ProducerSolver::class); |
|
|
$this->producerBuilder = $this->loadService(ProducerBuilder::class); |
|
|
$this->producerBuilder = $this->loadService(ProducerBuilder::class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->producerSolver->getConfig($pageSizeConfig, $producer) ?: PageSizer::DEFAULT_PAGE_SIZE ; |
|
|
return $this->producerSolver->getConfig($pageSizeConfig, $producer) ?: PageSizer::DEFAULT_PAGE_SIZE ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getPageSizeSummary(Producer $producer, string $entity, string $labelEntity) |
|
|
|
|
|
|
|
|
public function getPageSizeSummary(Producer $producer, string $entity, string $labelEntity): string |
|
|
{ |
|
|
{ |
|
|
return \Yii::$app->pageSizer->getForm($entity, $labelEntity, $this->getPageSize($producer, $entity)); |
|
|
|
|
|
|
|
|
return $this->pageSizer->getForm($entity, $labelEntity, $this->getPageSize($producer, $entity)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function updatePagesize(Producer $producer, string $entity, int $pageSize) |
|
|
public function updatePagesize(Producer $producer, string $entity, int $pageSize) |
|
|
{ |
|
|
{ |
|
|
$field = $this->getPageSizeConfigName($entity); |
|
|
$field = $this->getPageSizeConfigName($entity); |
|
|
|
|
|
|
|
|
if(isset($producer->$field)) { |
|
|
|
|
|
|
|
|
if(isset($producer->$field) && $this->pageSizer->isPageSizeExist($pageSize)) { |
|
|
$producer->$field = $pageSize; |
|
|
$producer->$field = $pageSize; |
|
|
$this->producerBuilder->update($producer); |
|
|
$this->producerBuilder->update($producer); |
|
|
} |
|
|
} |