Skip to content
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
7 changes: 5 additions & 2 deletions src/Engine/Mod/SimpleEquationMod.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public static function getType(): string

public function __invoke(Engine $engine, array $options): void
{
$operator = SqlEquationOperator::match($options['operator'])
?? throw new \InvalidArgumentException('Invalid equation operator provided');

$filter = SimpleEquationElement::define(
equationLeft: $options['operand1'],
equationOperator: $options['operator'],
equationOperator: $operator,
equationRight: $options['operand2'],
);

Expand Down Expand Up @@ -56,4 +59,4 @@ public function configureOptions(OptionsResolver $resolver): void
?? throw new \InvalidArgumentException('Invalid equation operator provided')
);
}
}
}
4 changes: 1 addition & 3 deletions src/Engine/Projector/InteractiveProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,11 @@ private function hydrateForm(FormInterface $form, ListSpecification $list): void
}
catch (OutOfBoundsException $exception)
{
$filterSourceId = $filterDefinition->getDataSource()->getFilterIdentifier();

throw new FlareException(
message: 'Filter form does not contain field: ' . $filterName,
previous: $exception,
method: __METHOD__,
source: $filterSourceId ? \sprintf('tl_flare_filter.id=%s', $filterSourceId) : 'filter inlined'
source: $filterDefinition->getDataSource()?->getFilterIdentifier() ?? 'filter inlined'
);
}

Expand Down
6 changes: 5 additions & 1 deletion src/FilterElement/SimpleEquationElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public function __invoke(FilterInvocation $inv, FilterQueryBuilder $qb): void
SqlEquationOperator::LESS_THAN_EQUALS => $qb->expr()->lte($operand, ':eq_right'),
SqlEquationOperator::LIKE => $qb->expr()->like($operand, ':eq_right'),
SqlEquationOperator::NOT_LIKE => $qb->expr()->notLike($operand, ':eq_right'),
SqlEquationOperator::IN => $qb->expr()->in($operand, ':eq_right'),
SqlEquationOperator::NOT_IN => $qb->expr()->notIn($operand, ':eq_right'),
SqlEquationOperator::IS_NULL => $qb->expr()->isNull($operand),
// the default arm below is a runtime safety net for operators added to the enum later
// @phpstan-ignore match.alwaysTrue
SqlEquationOperator::IS_NOT_NULL => $qb->expr()->isNotNull($operand),
default => null,
};
Expand Down Expand Up @@ -111,4 +115,4 @@ public static function define(

return $definition;
}
}
}
4 changes: 2 additions & 2 deletions src/Model/FilterModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FilterModel extends Model implements FilterDataSourceInterface, PtableInfe

public function getFilterIdentifier(): string
{
return (string) $this->id;
return \sprintf('%s.id=%s', static::$strTable, $this->id);
}

public function getFilterType(): string
Expand Down Expand Up @@ -116,4 +116,4 @@ public function __get($strKey)
default => parent::__get($strKey),
};
}
}
}
4 changes: 2 additions & 2 deletions src/Query/Executor/FilterExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function createCallbackException(
return new FilterException(
\sprintf('[FLARE] Query denied: %s / Callback: %s', $e->getMessage(), $errorMethod),
code: $e->getCode(), previous: $e, method: $errorMethod,
source: \sprintf('tl_flare_filter.id=%s', $filter->getDataSource()->getFilterIdentifier() ?: '0'),
source: $filter->getDataSource()?->getFilterIdentifier() ?? 'filter inlined',
);
}
}
}
Loading