"Fossies" - the Fresh Open Source Software Archive

Member "neos-development-collection-7.0.1/Neos.Media.Browser/Classes/Controller/ImageVariantController.php" (23 Feb 2021, 1544 Bytes) of package /linux/www/neos-development-collection-7.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ImageVariantController.php" see the Fossies "Dox" file reference documentation.

    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 }