protected function applyAdjustment(ImageAdjustmentInterface $adjustment)
{
$existingAdjustmentFound = false;
$newAdjustmentClassName = TypeHandling::getTypeForValue($adjustment);
foreach ($this->adjustments as $existingAdjustment) {
if (TypeHandling::getTypeForValue($existingAdjustment) === $newAdjustmentClassName) {
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
ObjectAccess::setProperty($existingAdjustment, $propertyName, $propertyValue);
}
$existingAdjustmentFound = true;
}
}
if (!$existingAdjustmentFound) {
$this->adjustments->add($adjustment);
$adjustment->setImageVariant($this);
$this->adjustments = $this->adjustments->matching(new Criteria(null, array('position' => 'ASC')));
}
$this->lastModified = new \DateTime();
}