Skip to content

Commit

Permalink
revert "disable=true" from yaml loader to modules/filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jygaulier committed Oct 23, 2024
1 parent 435f624 commit 7aece6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
22 changes: 3 additions & 19 deletions lib/php/rendition-factory/src/Config/YamlLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,8 @@ public function parse(string $content): BuildConfig
return $this->parseConfig($data);
}

private function removeDisabled(array $data): array
{
$out = [];
foreach ($data as $key => $value) {
if (is_array($value)) {
if ($value['enabled'] ?? true) {
$out[$key] = $this->removeDisabled($value);
}
} else {
$out[$key] = $value;
}
}

return $out;
}

private function parseConfig(array $data): BuildConfig
{
$data = $this->removeDisabled($data);

$families = [];
foreach ($data as $familyKey => $familyConfig) {
if (null === $family = FamilyEnum::tryFrom($familyKey)) {
Expand All @@ -78,7 +60,9 @@ private function parseFamilyConfig(array $data): FamilyBuildConfig

$transformations = [];
foreach ($data['transformations'] as $transformation) {
$transformations[] = $this->parseTransformation($transformation);
if($transformation['enabled'] ?? true) {
$transformations[] = $this->parseTransformation($transformation);
}
}

return new FamilyBuildConfig($transformations, $data['normalization'] ?? []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ private function doVideo(FormatInterface $ouputFormat, string $extension, InputF
/** @var Video $video */
$video = $ffmpeg->open($inputFile->getPath());

$filters = $options['filters'] ?? [];
$filters = array_values(array_filter($options['filters'] ?? [],
function($filter) {
return $filter['enabled'] ?? true;
}));

// first, turn the video into a clip
if (!empty($filters) && 'pre_clip' === $filters[0]['name']) {
Expand Down

0 comments on commit 7aece6d

Please sign in to comment.