mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-02 08:09:19 +08:00
Symfony 6.4 - Update graphql collection query return as paginator
This commit is contained in:
parent
8597c7fea2
commit
4e7cdd780d
2 changed files with 10 additions and 6 deletions
|
@ -29,6 +29,7 @@ namespace App\SystemConfig\DataProvider;
|
|||
|
||||
use ApiPlatform\Metadata\CollectionOperationInterface;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\Pagination\ArrayPaginator;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\SystemConfig\Entity\SystemConfig;
|
||||
use App\SystemConfig\Service\SystemConfigProviderInterface;
|
||||
|
@ -58,12 +59,13 @@ final class SystemConfigStateProvider implements ProviderInterface
|
|||
* @param Operation $operation
|
||||
* @param array $uriVariables
|
||||
* @param array $context
|
||||
* @return array|SystemConfig|null
|
||||
* @return ArrayPaginator|SystemConfig|null
|
||||
*/
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array|SystemConfig|null
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ArrayPaginator|SystemConfig|null
|
||||
{
|
||||
if ($operation instanceof CollectionOperationInterface) {
|
||||
return $this->systemConfigProvider->getAllSystemConfigs();
|
||||
$systemConfigs = $this->systemConfigProvider->getAllSystemConfigs();
|
||||
return new ArrayPaginator($systemConfigs, 0, count($systemConfigs));
|
||||
}
|
||||
|
||||
return $this->systemConfigProvider->getSystemConfig($uriVariables['id'] ?? '');
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace App\UserPreferences\DataProvider;
|
|||
|
||||
use ApiPlatform\Metadata\CollectionOperationInterface;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\Pagination\ArrayPaginator;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\UserPreferences\Entity\UserPreference;
|
||||
use App\UserPreferences\Service\UserPreferencesProviderInterface;
|
||||
|
@ -58,12 +59,13 @@ final class UserPreferenceStateProvider implements ProviderInterface
|
|||
* @param Operation $operation
|
||||
* @param array $uriVariables
|
||||
* @param array $context
|
||||
* @return iterable|UserPreference|null
|
||||
* @return ArrayPaginator|UserPreference|null
|
||||
*/
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array|UserPreference|null
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ArrayPaginator|UserPreference|null
|
||||
{
|
||||
if ($operation instanceof CollectionOperationInterface) {
|
||||
return $this->userPreferenceService->getAllUserPreferences();
|
||||
$preferences = $this->userPreferenceService->getAllUserPreferences();
|
||||
return new ArrayPaginator($preferences, 0, count($preferences));
|
||||
}
|
||||
|
||||
return $this->userPreferenceService->getUserPreference($uriVariables['id'] ?? '');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue