Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] Use boolean arguments for mapped parameters directly #652

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/Asset/MappedParameter/ImageDownloadConfigParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public function __construct(
private ?int $quality = 85,
private ?int $dpi = null,
private ?string $positioning = 'center',
private string $cover = 'false',
private string $frame = 'false',
private string $contain = 'false',
private string $forceResize = 'false',
private bool $cover = false,
private bool $frame = false,
private bool $contain = false,
private bool $forceResize = false,
) {

$this->validateResizeMode();
Expand Down Expand Up @@ -100,25 +100,22 @@ public function getPositioning(): ?string

public function getForceResize(): bool
{
return $this->forceResize === 'true'; // TODO: symfony 7.1 will support bool type
return $this->forceResize;
}

public function hasCover(): bool
{
// TODO: symfony 7.1 will support bool type
return $this->cover === 'true';
return $this->cover;
}

public function hasFrame(): bool
{
// TODO: symfony 7.1 will support bool type
return $this->frame === 'true';
return $this->frame;
}

public function hasContain(): bool
{
// TODO: symfony 7.1 will support bool type
return $this->contain === 'true';
return $this->contain;
}

private function isValidWidth(): bool
Expand Down
16 changes: 8 additions & 8 deletions src/Asset/MappedParameter/VideoImageStreamConfigParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
public function __construct(
private ?int $width = null,
private ?int $height = null,
private ?string $aspectRatio = null,
private ?string $frame = null,
private ?string $async = null,
private bool $aspectRatio = false,
private bool $frame = false,
private bool $async = false,
) {
if ($this->frame === 'true' && ($this->width === null || $this->height === null)) {
if ($this->frame && ($this->width === null || $this->height === null)) {
throw new InvalidThumbnailConfigurationException(
'Width and height must be set when using frame configuration'
);
}
if ($this->aspectRatio === 'true' && $this->width === null) {
if ($this->aspectRatio && $this->width === null) {
throw new InvalidThumbnailConfigurationException(
'Width must be set when using aspectRatio configuration'
);
Expand All @@ -54,16 +54,16 @@ public function getHeight(): ?int

public function getAspectRatio(): bool
{
return $this->aspectRatio === 'true'; // TODO: symfony 7.1 will support bool type
return $this->aspectRatio;
}

public function getFrame(): bool
{
return $this->frame === 'true'; // TODO: symfony 7.1 will support bool type
return $this->frame;
}

public function getAsync(): bool
{
return $this->async === 'true'; // TODO: symfony 7.1 will support bool type
return $this->async;
}
}
2 changes: 2 additions & 0 deletions src/Asset/Service/BinaryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ public function streamVideoImageThumbnail(
if ($imageConfig->getHeight()) {
$imageParameters['height'] = $imageConfig->getHeight();
}

if ($imageConfig->getAspectRatio()) {
$imageParameters['aspectratio'] = $imageConfig->getAspectRatio();
}

if ($imageConfig->getFrame()) {
$imageParameters['frame'] = $imageConfig->getFrame();
}
Expand Down
6 changes: 3 additions & 3 deletions src/DataIndex/Request/DataObjectParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function __construct(
int $pageSize = 10,
?int $parentId = null,
?string $idSearchTerm = null,
?string $excludeFolders = null,
bool $excludeFolders = false,
?string $path = null,
?string $pathIncludeParent = null,
?string $pathIncludeDescendants = null,
bool $pathIncludeParent = false,
bool $pathIncludeDescendants = false,
private ?string $className = null
) {
parent::__construct(
Expand Down
12 changes: 6 additions & 6 deletions src/DataIndex/Request/ElementParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function __construct(
int $pageSize = 10,
private ?int $parentId = null,
private ?string $idSearchTerm = null,
private ?string $excludeFolders = null,
private bool $excludeFolders = false,
private ?string $path = null,
private ?string $pathIncludeParent = null,
private ?string $pathIncludeDescendants = null,
private bool $pathIncludeParent = false,
private bool $pathIncludeDescendants = false,
private ?UserInterface $user = null
) {
parent::__construct($page, $pageSize);
Expand All @@ -60,7 +60,7 @@ public function getIdSearchTerm(): ?string

public function getExcludeFolders(): bool
{
return $this->excludeFolders === 'true'; // TODO: symfony 7.1 will support bool type
return $this->excludeFolders;
}

public function getPath(): ?string
Expand All @@ -70,12 +70,12 @@ public function getPath(): ?string

public function getPathIncludeParent(): bool
{
return $this->pathIncludeParent === 'true'; // TODO: symfony 7.1 will support bool type
return $this->pathIncludeParent;
}

public function getPathIncludeDescendants(): bool
{
return $this->pathIncludeDescendants === 'true'; // TODO: symfony 7.1 will support bool type
return $this->pathIncludeDescendants;
}

public function getUser(): ?UserInterface
Expand Down
4 changes: 2 additions & 2 deletions src/Document/MappedParameter/ExcludeMainSiteParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
final readonly class ExcludeMainSiteParameter
{
public function __construct(
private ?string $excludeMainSite = null
private bool $excludeMainSite = false
) {
}

public function getExcludeMainSite(): bool
{
return $this->excludeMainSite === 'true'; // TODO: symfony 7.1 will support bool type
return $this->excludeMainSite;
}
}
Loading