Update the options list in the event.

@param GetPropertyOptionsEvent $event The event being emitted.
@param array                   $value The options array.

@return void
962268
public function update($event, $value)
    {
        if (null === $value) {
            return;
        }

        $event->setOptions($value);
        $event->stopPropagation();
    }
4996
public function getOptions(GetOptionsEvent $event)
    {
        // Check the context.
        $allowedProperties = array('lookupservice', 'second_attr_id', 'single_attr_id');
        if (!$this->isAllowedProperty($event, 'tl_metamodel_filtersetting', $allowedProperties)
            || 'lookupservice' !== $event->getSubPropertyName()
        ) {
            return;
        }

        $resolveClass = (array) $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'];

        $domain  = 'tl_metamodel_filtersetting';
        $options = [];
        foreach (\array_keys($resolveClass) as $name) {
            $options[$name] = $this->translator->trans($domain . '.perimetersearch.' . $name, [], 'contao_' . $domain);
        }

        $event->setOptions($options);
    }
778237
public function handleOriginalOptions(GetOptionsEvent $event)
    {
        $environment = $event->getEnvironment();

        if (!$this->scopeDeterminator->currentScopeIsBackend()
            || ('select' !== $environment->getInputProvider()->getParameter('act'))
            || ('edit' !== $environment->getInputProvider()->getParameter('select'))
        ) {
            return;
        }

        $model = $event->getModel();

        if (!($propertyName = $this->getOriginalPropertyName($event->getPropertyName(), ModelId::fromModel($model)))
            || !$model->getProperty($propertyName)
        ) {
            return;
        }

        $originalWidget       = clone $event->getWidget();
        $originalWidget->id   = $propertyName;
        $originalWidget->name = $propertyName;

        $originalOptionsEvent =
            new GetOptionsEvent(
                $propertyName,
                $event->getSubPropertyName(),
                $event->getEnvironment(),
                $model,
                $originalWidget,
                $event->getOptions()
            );

        $environment->getEventDispatcher()->dispatch(GetOptionsEvent::NAME, $originalOptionsEvent);

        $event->setOptions($originalOptionsEvent->getOptions());

        $event->stopPropagation();
    }
1200989
protected function setOptional($key, $value) {
        if (!$this->has($key))
            $this->set($key, $value);
    }
946872
public function setOption($key, $value): void
    {
        $method = 'set' . Str::toCamelCase($key);
        if (method_exists($this, $method)) {
            $this->$method($value);
        } else {
            $this->options[$key] = $value;
        }
    }
541930
public function saveOption($optionName, $value)
    {
        $options = $this->getOption();
        $options[$optionName] = $value;

        if ($this->multiSite) {
            update_site_option($this->settingsName, $options);
        } else {
            update_option($this->settingsName, $options);
        }
    }
192318
public function getOptions(GetOptionsEvent $event)
    {
        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getPropertyName() !== 'combinedvalues_fields')
            || ($event->getSubPropertyName() !== 'field_attribute')
        ) {
            return;
        }

        $model     = $event->getModel();
        $metaModel = $this->getMetaModelById($model->getProperty('pid'));

        if (!$metaModel) {
            return;
        }

        $result = [];
        // Add meta fields.
        $result['meta'] = self::getMetaModelsSystemColumns();

        // Fetch all attributes except for the current attribute.
        foreach ($metaModel->getAttributes() as $attribute) {
            if ($attribute->get('id') === $model->getId()) {
                continue;
            }

            $type = $event
                ->getEnvironment()
                ->getTranslator()
                ->translate('typeOptions.'.$attribute->get('type'), 'tl_metamodel_attribute');

            if ($type == 'typeOptions.'.$attribute->get('type')) {
                $type = $attribute->get('type');
            }

            $result['attributes'][$attribute->getColName()] = \sprintf(
                '%s [%s]',
                $attribute->getName(),
                $type
            );
        }

        $event->setOptions($result);
    }
1117977
public function update($event, $value)
    {
        if (null === $value) {
            return;
        }

        $event->setHtml($value);
        $event->stopPropagation();
    }
497947
protected function addOption(string $name, string $value): void
    {
        $this->options[$name] = $value;
    }
220701
public function setOption($option, $value)
    {
        if (null !== $this->logger) {
            $this->logger->startMethod('setOption', ['option' => $option, 'value' => $value]);
        }

        if (!$this->setOptionImpl($option, $value)) {
            $this->stopMethod();

            return false;
        }

        $this->setResultOK();
        $this->stopMethod();

        return true;
    }
843567
public static function event($value): void
    {
        if (false === self::message($value)) {
            throw new Exception\InvalidEvent($value);
        }
    }
28841
public function setValue(string $value) : void
    {
        $this->value = $value;
        foreach ((array)$this as $option) {
            if ($option->getValue() == $value) {
                $option->selected();
            } else {
                $option->unselected();
            }
        }
    }
143883
private function isEventForMe(GetOptionsEvent $event)
    {
        $input = $event->getEnvironment()->getInputProvider();

        if ($input->hasValue('type')) {
            $type = $input->getValue('type');
        }

        if (empty($type)) {
            $type = $event->getModel()->getProperty('type');
        }

        return
            ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($type !== 'translatedalias')
            || ($event->getPropertyName() !== 'talias_fields')
            || ($event->getSubPropertyName() !== 'field_attribute');
    }
94006
protected function onSetFormValue(string $value): void
    {
        foreach ($this->options as $option) {
            $isMatch = ($value === $option->getValue());
            $option->setSelected($isMatch);

            if ($isMatch) {
                $this->value = $value;
            }
        }

        parent::onSetFormValue($value);
    }
63172
public function setOption($name, $value=null)
    {
        if (is_array($name)) {
            $this->options = array_merge($this->options, $name);
        } else {
            $this->options[$name] = $value;
        }
    }
113094
public function updateFeatureProductValue(FeatureProductUpdateEvent $event)
    {
        // Prepare the FeatureAv's ID
        $featureAvId = $event->getFeatureValue();

        // Search for existing FeatureProduct
        $featureProductQuery = FeatureProductQuery::create()
            ->filterByProductId($event->getProductId())
            ->filterByFeatureId($event->getFeatureId())
        ;

        // If it's not a free text value, we can filter by the event's featureValue (which is an ID)
        if ($event->getFeatureValue() !== null && $event->getIsTextValue() === false) {
            $featureProductQuery->filterByFeatureAvId($featureAvId);
        }

        $featureProduct = $featureProductQuery->findOne();

        // If the FeatureProduct does not exist, create it
        if ($featureProduct === null) {
            $featureProduct = new FeatureProduct();

            $featureProduct
                ->setDispatcher($this->eventDispatcher)
                ->setProductId($event->getProductId())
                ->setFeatureId($event->getFeatureId())
            ;

            // If it's a free text value, create a FeatureAv to handle i18n
            if ($event->getIsTextValue() === true) {
                $featureProduct->setIsFreeText(true);

                $createFeatureAvEvent = new FeatureAvCreateEvent();
                $createFeatureAvEvent
                    ->setFeatureId($event->getFeatureId())
                    ->setLocale($event->getLocale())
                    ->setTitle($event->getFeatureValue());
                $this->eventDispatcher->dispatch(TheliaEvents::FEATURE_AV_CREATE, $createFeatureAvEvent);

                $featureAvId = $createFeatureAvEvent->getFeatureAv()->getId();
            }
        } // Else if the FeatureProduct exists and is a free text value
        elseif ($featureProduct !== null && $event->getIsTextValue() === true) {
            // Get the FeatureAv
            $freeTextFeatureAv = FeatureAvQuery::create()
                ->filterByFeatureProduct($featureProduct)
                ->findOneByFeatureId($event->getFeatureId());

            // Get the FeatureAvI18n by locale
            $freeTextFeatureAvI18n = FeatureAvI18nQuery::create()
                ->filterById($freeTextFeatureAv->getId())
                ->findOneByLocale($event->getLocale());

            // Nothing found for this lang and the new value is not empty : create FeatureAvI18n
            if ($freeTextFeatureAvI18n === null && !empty($featureAvId)) {
                $featureAvI18n = new FeatureAvI18n();
                $featureAvI18n
                    ->setId($freeTextFeatureAv->getId())
                    ->setLocale($event->getLocale())
                    ->setTitle($event->getFeatureValue())
                    ->save();

                $featureAvId = $featureAvI18n->getId();
            } // Else if i18n exists but new value is empty : delete FeatureAvI18n
            elseif ($freeTextFeatureAvI18n !== null && empty($featureAvId)) {
                $freeTextFeatureAvI18n->delete();

                // Check if there are still some FeatureAvI18n for this FeatureAv
                $freeTextFeatureAvI18ns = FeatureAvI18nQuery::create()
                    ->findById($freeTextFeatureAv->getId());

                // If there are no more FeatureAvI18ns for this FeatureAv, remove the corresponding FeatureProduct & FeatureAv
                if (\count($freeTextFeatureAvI18ns) == 0) {
                    $deleteFeatureProductEvent = new FeatureProductDeleteEvent($event->getProductId(), $event->getFeatureId());
                    $this->eventDispatcher->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $deleteFeatureProductEvent);

                    $deleteFeatureAvEvent = new FeatureAvDeleteEvent($freeTextFeatureAv->getId());
                    $this->eventDispatcher->dispatch(TheliaEvents::FEATURE_AV_DELETE, $deleteFeatureAvEvent);
                }
                return;
            } // Else if a FeatureAvI18n is found and the new value is not empty : update existing FeatureAvI18n
            elseif ($freeTextFeatureAvI18n !== null && !empty($featureAvId)) {
                $freeTextFeatureAvI18n->setTitle($featureAvId);
                $freeTextFeatureAvI18n->save();

                $featureAvId = $freeTextFeatureAvI18n->getId();
            } //To prevent Integrity constraint violation
            elseif (empty($featureAvId)) {
                return;
            }
        }

        $featureProduct->setFeatureAvId($featureAvId);

        $featureProduct->save();

        $event->setFeatureProduct($featureProduct);
    }
1055129
private function update_option( $name, $value ) {
            $this->_data[ $name ] = $value;

            $this->_storage->set_option( $this->_option_name, $this->_data, true );
        }