$upserts =
[];
foreach ($ruleConditions as $ruleCondition) { $payload =
$ruleCondition->
toArray($defaultLocale);
$payload['identifier'
] =
sprintf('app\\%s_%s',
$manifest->
getMetadata()->
getName(),
$ruleCondition->
getIdentifier());
$payload['script'
] =
$this->scriptReader->
getScriptContent( self::CONDITION_SCRIPT_DIR .
$ruleCondition->
getScript(),
$app->
getPath() );
$payload['appId'
] =
$appId;
$payload['active'
] =
$app->
isActive();
$payload['constraints'
] =
$this->
hydrateConstraints($payload['constraints'
]);
/** @var AppScriptConditionEntity|null $existing */
$existing =
$existingRuleConditions->
filterByProperty('identifier',
$payload['identifier'
])->
first();
if ($existing) { $existingRuleConditions->
remove($existing->
getId());
$payload['id'
] =
$existing->
getId();
} $upserts[] =
$payload;
}