1 <?php 2 namespace Neos\Media\Browser\Controller; 3 4 use Neos\Flow\Annotations as Flow; 5 use Neos\Flow\Mvc\Controller\ActionController; 6 use Neos\Flow\Property\TypeConverter\PersistentObjectConverter; 7 use Neos\Media\Browser\Domain\ImageMapper; 8 use Neos\Media\Domain\Model\Adjustment\CropImageAdjustment; 9 use Neos\Media\Domain\Model\ImageVariant; 10 use Neos\Media\Domain\Repository\AssetRepository; 11 12 /** 13 * 14 */ 15 class ImageVariantController extends ActionController 16 { 17 /** 18 * @Flow\Inject 19 * @var AssetRepository 20 */ 21 protected $assetRepository; 22 23 public function initializeUpdateAction() 24 { 25 $mappingConfiguration = $this->arguments->getArgument('imageVariant')->getPropertyMappingConfiguration(); 26 $mappingConfiguration->allowAllProperties(); 27 $mappingConfiguration->getConfigurationFor('adjustments')->allowAllProperties(); 28 $mappingConfiguration->getConfigurationFor('adjustments')->getConfigurationFor('*')->allowAllProperties(); 29 $mappingConfiguration->getConfigurationFor('adjustments')->getConfigurationFor(CropImageAdjustment::class)->allowAllProperties(); 30 $mappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true); 31 } 32 33 /** 34 * @param ImageVariant $imageVariant 35 */ 36 public function updateAction(ImageVariant $imageVariant) 37 { 38 $this->assetRepository->update($imageVariant); 39 return json_encode((new ImageMapper($imageVariant))->getMappingResult()); 40 } 41 }