getPresetData example

/** * {@inheritdoc} */
    public function load($presetId)
    {
        $preset = $this->modelManager->getRepository(Preset::class)->find($presetId);

        if (!$preset) {
            throw new NoResultException();
        }

        $presetData = json_decode($preset->getPresetData(), true);

        if (empty($presetData['elements'])) {
            return $preset->getPresetData();
        }

        $presetData['elements'] = $this->refreshElementData($presetData['elements']);

        $preset->setPresetData(json_encode($presetData));

        if (!$preset->getAssetsImported()) {
            $preset->setAssetsImported(true);
        }
'%s%s%s',
            sys_get_temp_dir(),
            DIRECTORY_SEPARATOR,
            basename($this->Request()->get('filePath'))
        );

        $preset = $this->container->get('shopware.emotion.emotion_importer')->import($filePath);

        $this->View()->assign([
            'success' => true,
            'presetId' => $preset->getId(),
            'presetData' => $preset->getPresetData(),
            'emotionTranslations' => $preset->getEmotionTranslations(),
        ]);
    }

    /** * Execute cleanup on imported emotion files. * * @throws InvalidArgumentException If the passed filePath is empty (code: 1) * * @return void */
    
$modelManager = $this->presetResource->getManager();

        /** @var PresetMetaDataInterface $metaData */
        foreach ($presetMetaData as $metaData) {
            $presetData = [
                'name' => $metaData->getName(),
                'premium' => $metaData->getPremium(),
                'custom' => $metaData->getCustom(),
                'thumbnail' => $metaData->getThumbnail(),
                'preview' => $metaData->getPreview(),
                'translations' => $metaData->getTranslations(),
                'presetData' => json_encode($metaData->getPresetData()),
                'requiredPlugins' => $metaData->getRequiredPlugins(),
                'assetsImported' => $metaData->getAssetsImported(),
            ];

            $slugifiedName = $this->slugService->slugify($metaData->getName());
            $preset = $modelManager->getRepository(Preset::class)->findOneBy(['name' => $slugifiedName]);

            if (!$preset) {
                $this->presetResource->create($presetData);

                continue;
            }


    /** * {@inheritdoc} */
    public function importElementAssets(Preset $preset$elementSyncKey)
    {
        if ($preset->getAssetsImported()) {
            throw new PresetAssetImportException('The assets for this preset are already imported.');
        }

        $presetData = json_decode($preset->getPresetData(), true);

        if (!$presetData || !\is_array($presetData) || !\array_key_exists('elements', $presetData)) {
            throw new PresetAssetImportException(sprintf('The preset data of the %s preset seems to be invalid.', $preset->getName()));
        }

        // continue if no sync data present or we just have an assets key which is empty         if (empty($presetData['syncData'])
            || (\count($presetData['syncData']) === 1 && empty($presetData['syncData']['assets']))
        ) {
            return;
        }

        
$filename = $this->rootDirectory . '/files/downloads/' . $name . time() . '.zip';

        if ($zip->open($filename, ZipArchive::CREATE) !== true) {
            throw new Exception(sprintf('Could not create zip file "%s"!', $filename));
        }

        $emotionData = $this->transformer->transform($emotionId, true);

        $preset = $this->createHiddenPreset($emotionData);
        $preset = $this->synchronizer->prepareAssetExport($preset);

        $presetData = json_decode($preset->getPresetData(), true);
        $syncData = new ParameterBag($presetData['syncData']);
        $assets = $syncData->get('assets', []);

        $zip->addEmptyDir('images');

        foreach ($assets as &$path) {
            $fileContent = $this->mediaService->read($path);
            if ($fileContent === false) {
                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.