Closed dreamsbond closed 7 years ago
I can look closer this weekend.
in the meantime, i think is it possible to make MAX_LIMIT_SIZE accessible to the FluteSetting?
@neomerx i do the same, it turns out that the static::KEY_RELATIONSHIP_PAGING_SIZE in config folder does not override the DEFAULT_LIMIT_SIZE of 20 in pagination strategy
static::KEY_RELATIONSHIP_PAGING_SIZE applies to the
public function __construct(int $defaultPageLimit = self::DEFAULT_LIMIT_SIZE)
{
$this->defaultPageLimit = $defaultPageLimit;
}
while without changing the MAX_LIMIT_SIZE in PaginationStrategy
class PaginationStrategy implements PaginationStrategyInterface
{
/** Paging constant */
const DEFAULT_LIMIT_SIZE = 20;
/** Paging constant */
const MAX_LIMIT_SIZE = 100;
i found no effect on having page size to, say a 10000 to return the whole collection
I found an issue with selecting min/max for page size. Can you try it with updated strategy?
@dreamsbond would appreciate your feedback
@neomerx sorry for late reply, feel unwell these days. will try it out and get you back very soon.
@neomerx the static::KEY_RELATIONSHIP_PAGING_SIZE does finally reflect properly.
but another question is that, the MAX_LIMIT_SIZE of 100 was not accessible via FluteSettings
it only limits to a max size of 100 records to return no matter how i change the value of static::KEY_RELATIONSHIP_PAGING_SIZE;
besides, for relationships like .../user/1/relationships/posts. is it capable to do the same way specifying the size of records return?
or is it capable to make an default global options for assigning the numbers of records return?
@dreamsbond nice idea to add MAX_LIMIT_SIZE as a setting
added to develop
branch. Will be released today/tomorrow.
merged to master
Hi, I found the static::KEY_RELATIONSHIP_PAGING_SIZE in flutesetting is not longer available. The settings of DEFAULT_PAGE_SIZE and DEFAULT_MAX_PAGE_SIZE does not applies to relationship links and resources.
Hi, I found the static::KEY_RELATIONSHIP_PAGING_SIZE in flutesetting is not longer available.
I guess, your question is about how to manage to load data in relationships. The library will ask the container for RelationshipPaginationStrategyInterface and then getParameters to have database offset and limit. By default, it returns default values 0
for offset and DEFAULT_PAGE_SIZE
for the limit.
You can put a custom implementation of the interface to the container.
The settings of DEFAULT_PAGE_SIZE and DEFAULT_MAX_PAGE_SIZE does not applies to relationship links and resources.
I think you are asking about customizing RelationshipPaginationStrategyInterface
behaviour (see above).
Do you mean i need to implement RelationshipPaginationStrategyInterface in Container folder?
Sorry for late reply. Yes, you will need to implement the interface that suits your custom requirements. Here is the template
<?php declare(strict_types=1);
namespace App\Container;
use Limoncello\Contracts\Application\ContainerConfiguratorInterface;
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface;
use Limoncello\Flute\Contracts\Api\RelationshipPaginationStrategyInterface;
/**
* @package App\Container
*/
class PaginationConfigurator implements ContainerConfiguratorInterface
{
/** @var callable */
const CONFIGURATOR = [self::class, self::CONTAINER_METHOD_NAME];
/**
* @inheritdoc
*/
public static function configureContainer(LimoncelloContainerInterface $container): void
{
$container[RelationshipPaginationStrategyInterface::class] = new class implements RelationshipPaginationStrategyInterface
{
/**
* @param string $rootClass
* @param string $class
* @param string $path
* @param string $relationshipName
*
* @return array [$offset, $limit]
*/
public function getParameters(string $rootClass, string $class, string $path, string $relationshipName): array
{
// TODO: Implement getParameters() method.
}
};
}
}
@neomerx. It is better than do it at each getPageLimitRule() in ReadQuery, thanks @neomerx !
@neomerx I found the captioned does not reflect in the JsonApi