setElement example


    public function install()
    {
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_Auth', 'onInitResourceAuth');
        $this->subscribeEvent('Enlight_Controller_Action_PreDispatch', 'onPreDispatchBackend');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_BackendSession', 'onInitResourceBackendSession');

        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);
        $form->setParent($parent);
        $form->setLabel('Backend');
        $form->setElement('select', 'backendLocales', [
            'store' => 'base.Locale',
            'label' => 'Auswählbare Sprachen',
            'value' => [1, 2],
            'required' => true,
            'multiSelect' => true,
        ]);
        $form->setElement('interval', 'backendTimeout', [
            'label' => 'Timeout',
            'required' => true,
            'value' => 7200,
        ]);

        
continue;
            }

            // Simple data validation             if (!$this->validateData($elementData$valueData['value'])) {
                continue;
            }

            $valueData['value'] = $this->prepareValue($elementData$valueData['value']);

            $value = new Value();
            $value->setElement($element);
            $value->setShop($shop);
            $value->setValue($valueData['value']);
            $values[$shop->getId()] = $value;
        }

        $this->beforeSaveElement($elementData);

        $values = Shopware()->Events()->filter(
            'Shopware_Controllers_Backend_Config_Before_Save_Config_Element',
            $values,
            [
                

    }

    /** * Translates the plugin form */
    private function addForm(): void
    {
        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Frontend']);
        $form->setParent($parent);
        $form->setElement('checkbox', 'show', [
            'label' => 'Tag-Cloud anzeigen',
            'value' => true,
            'scope' => Element::SCOPE_SHOP,
        ]);
        $form->setElement('text', 'controller', [
            'label' => 'Controller-Auswahl',
            'value' => 'index, listing',
            'scope' => Element::SCOPE_SHOP,
        ]);
        $form->setElement('text', 'tagCloudClass', [
            'label' => 'Name der Tag-Klasse',
            
$removedValues = [];
        foreach ($element->getValues() as $valueModel) {
            $removedValues[] = $valueModel;
            $modelManager->remove($valueModel);
        }
        $modelManager->flush($removedValues);

        $values = [];
        // Do not save default value         if ($value !== $element->getValue()) {
            $valueModel = new Shopware\Models\Config\Value();
            $valueModel->setElement($element);
            $valueModel->setShop($shop);
            $valueModel->setValue($value);
            $values[$shop->getId()] = $valueModel;
        }

        $element->setValues(new ArrayCollection($values));
        $modelManager->flush($element);
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Read a given config by name * * @param string $configName * @param string $defaultValue * * @return array<array-key, mixed>|bool|float|int|string|null */
return $hashes;
    }

    /** * Crate config form elements */
    protected function createForm(): void
    {
        $form = $this->Form();

        $form->setElement('combo', 'defaultPasswordEncoderName', [
            'label' => 'Passwörter verschlüsseln mit...',
            'editable' => false,
            'value' => 'Auto',
            'valueField' => 'id', 'displayField' => 'id',
            'triggerAction' => 'all',
            'store' => 'base.EncoderName',
        ]);

        $form->setElement('boolean', 'liveMigration', [
            'description' => 'Sollen vorhandene Benutzer-Passwörter mit anderen Passwort-Algorithmen beim nächsten Einloggen erneut gehasht werden? Das geschieht voll automatisch im Hintergrund, so dass die Passwörter sukzessiv auf einen neuen Algorithmus umgestellt werden können.',
            'label' => 'Live Migration',
            
return false;
    }

    private function createForm(): void
    {
        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Other']);
        $form->setParent($parent);
        $form->setName('CronSecurity');
        $form->setLabel('Cron-Sicherheit');

        $form->setElement('text', 'cronSecureAllowedKey', [
            'label' => 'Gültiger Schlüssel',
            'description' => 'Hinterlegen Sie hier einen Key zum Ausführen der Cronjobs.',
            'required' => false,
            'value' => '',
        ]);
        $form->setElement('text', 'cronSecureAllowedIp', [
            'label' => 'Zulässige IP(s)',
            'description' => 'Nur angegebene IP-Adressen können die Cron Anfragen auslösen. Mehrere IP-Adressen müssen durch ein \';\' getrennt werden.',
            'required' => false,
            'value' => '',
        ]);
        


    public function __clone()
    {
        $this->id = null;
        $this->emotionId = null;

        $dataArray = [];
        foreach ($this->data as $data) {
            $newData = clone $data;

            $newData->setElement($this);

            $dataArray[] = $newData;
        }

        $this->data = new ArrayCollection($dataArray);

        $viewportData = [];
        foreach ($this->viewports as $viewport) {
            $newViewport = clone $viewport;

            $newViewport->setElement($this);

            
$this->translations = $translations;
    }

    /** * @param ElementTranslation $translation * * @return Element */
    public function addTranslation($translation)
    {
        $this->translations->add($translation);
        $translation->setElement($this);

        return $this;
    }

    /** * @return bool */
    public function hasTranslations()
    {
        return $this->translations->count() > 0;
    }

    
'onPostDispatch'
        );
    }

    private function createForm(): void
    {
        $form = $this->Form();

        $parent = $this->Forms()->findOneBy(['name' => 'Frontend']);
        $form->setParent($parent);

        $form->setElement('checkbox', 'show', [
            'label' => 'Menü anzeigen',
            'value' => 1,
            'scope' => Element::SCOPE_SHOP,
        ]);

        $form->setElement('number', 'hoverDelay', [
            'label' => 'Hover Verzögerung (ms)',
            'value' => 250,
            'scope' => Element::SCOPE_SHOP,
        ]);

        
$element = $modelManager->getRepository(ConfigElement::class)->findOneBy(['name' => $name]);
        if (!$element instanceof ConfigElement) {
            throw new ModelNotFoundException(ConfigElement::class$name, 'name');
        }

        $value = $element->getValues()->filter(static fn (Value $value) => $value->getShopId() === $shopId)->first();

        if ($value instanceof Value) {
            $value->setValue($inputValue);
        } else {
            $value = new Value();
            $value->setElement($element);
            $value->setShop($shop);
            $value->setValue($inputValue);

            $modelManager->persist($value);
        }

        $modelManager->flush($value);

        return 0;
    }
}


            if (isset($element['description']['en'])) {
                $options['description'] = $element['description']['en'];
            }

            if ($element['type'] === 'password') {
                $element['type'] = 'text';
                $options['inputType'] = 'password';
            }

            $form->setElement($element['type']$element['name']$options);
        }

        if (isset($config['description'])) {
            foreach ($config['description'] as $lang => $text) {
                $translations[$lang]['plugin_form']['description'] = $text;
            }
        }

        if (isset($config['label'])) {
            foreach ($config['label'] as $lang => $text) {
                $translations[$lang]['plugin_form']['label'] = $text;
            }

    public function installForm()
    {
        $form = $this->Form();

        /** @var Form $parent */
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);

        $form->setParent($parent);
        $form->setElement('textarea', 'cacheControllers', [
            'label' => 'Cache-Controller / Zeiten',
            'value' => "frontend/listing 3600\r\n" .
            "frontend/index 3600\r\n" .
            "frontend/detail 3600\r\n" .
            "frontend/campaign 14400\r\n" .
            "widgets/listing 14400\r\n" .
            "frontend/custom 14400\r\n" .
            "frontend/forms 14400\r\n" .
            "frontend/sitemap 14400\r\n" .
            "frontend/blog 14400\r\n" .
            "widgets/index 3600\r\n" .
            
$this->subscribeEvent(
            'Enlight_Controller_Front_RouteShutdown',
            'onRouteShutdown',
            -100
        );

        $form = $this->Form();
        /** @var \Shopware\Models\Config\Form $parent */
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);
        $form->setParent($parent);

        $form->setElement('boolean', 'sql_protection', ['label' => 'SQL-Injection-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'xss_protection', ['label' => 'XSS-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'rfi_protection', ['label' => 'RemoteFileInclusion-Schutz aktivieren', 'value' => true]);
        $form->setElement('boolean', 'strip_tags', ['label' => 'Global strip_tags verwenden', 'value' => true]);
        $form->setElement('textarea', 'own_filter', ['label' => 'Eigener Filter', 'value' => null]);

        return true;
    }

    /** * @return void */
    


        /** @var Value|null $valueModel */
        $valueModel = $valueRepository->findOneBy(['shopId' => $shopId, 'element' => $element]);

        if ($valueModel === null) {
            if ($value === $parentValue || $value === null) {
                return;
            }

            $valueModel = new Value();
            $valueModel->setElement($element);
            $valueModel->setShopId($shopId);
            // serialize done by Doctrine             $valueModel->setValue($value);

            $this->modelManager->persist($valueModel);
            try {
                $this->modelManager->flush($valueModel);
            } catch (OptimisticLockException $e) {
                throw new WriterException('Failed writing to database', 0, $e);
            }

            
if ($element->getType() === 'theme-media-selection') {
                $data['value'] = $this->mediaService->normalize($data['value']);
            }

            // Don't save default values             if ($element->getDefaultValue() === $data['value']) {
                $element->getValues()->removeElement($value);
                continue;
            }

            $value->setShop($shop);
            $value->setElement($element);
            $value->setValue($data['value']);
        }

        $this->entityManager->flush();
    }

    /** * Translates the theme meta data. * * @return array */
    
Home | Imprint | This part of the site doesn't use cookies.