*/ final class ExpressionLanguageExclusionStrategy { /** * @var ExpressionEvaluatorInterface */ private $expressionEvaluator; public function __construct(ExpressionEvaluatorInterface $expressionEvaluator) { $this->expressionEvaluator = $expressionEvaluator; } /** * {@inheritDoc} */ public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext): bool { if (null === $property->excludeIf) { return false; } $variables = [ 'context' => $navigatorContext, 'property_metadata' => $property, ]; if ($navigatorContext instanceof SerializationContext) { $variables['object'] = $navigatorContext->getObject(); } else { $variables['object'] = null; } if (($property->excludeIf instanceof Expression) && ($this->expressionEvaluator instanceof CompilableExpressionEvaluatorInterface)) { return $this->expressionEvaluator->evaluateParsed($property->excludeIf, $variables); } return $this->expressionEvaluator->evaluate($property->excludeIf, $variables); } }