PreSetDataEvent example



        if ($this->lockSetData) {
            throw new RuntimeException('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.');
        }

        $this->lockSetData = true;
        $dispatcher = $this->config->getEventDispatcher();

        // Hook to change content of the model data before transformation and mapping children         if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA)) {
            $event = new PreSetDataEvent($this$modelData);
            $dispatcher->dispatch($event, FormEvents::PRE_SET_DATA);
            $modelData = $event->getData();
        }

        // Treat data as strings unless a transformer exists         if (\is_scalar($modelData) && !$this->config->getViewTransformers() && !$this->config->getModelTransformers()) {
            $modelData = (string) $modelData;
        }

        // Synchronize representations - must not change the content!         // Transformation exceptions are not caught on initialization
Home | Imprint | This part of the site doesn't use cookies.