isRoot example

            FormEvents::POST_SUBMIT => ['postSubmit', -255],
        ];
    }

    /** * Listener for the {@link FormEvents::POST_SET_DATA} event. * * @return void */
    public function postSetData(FormEvent $event)
    {
        if ($event->getForm()->isRoot()) {
            // Collect basic information about each form             $this->dataCollector->collectConfiguration($event->getForm());

            // Collect the default data             $this->dataCollector->collectDefaultData($event->getForm());
        }
    }

    /** * Listener for the {@link FormEvents::POST_SUBMIT} event. * * @return void */
$this->serverParams = $serverParams ?? new ServerParams();
    }

    /** * @return void */
    public function preSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        $postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded();

        if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) {
            $data = $event->getData();

            $csrfValue = \is_string($data[$this->fieldName] ?? null) ? $data[$this->fieldName] : null;
            $csrfToken = new CsrfToken($this->tokenId, $csrfValue);

            if (null === $csrfValue || !$this->tokenManager->isTokenValid($csrfToken)) {
                $errorMessage = $this->errorMessage;

                if (null !== $this->translator) {
                    $errorMessage = $this->translator->trans($errorMessage[]$this->translationDomain);
                }

                
'password' => $event->getData(),
        ];
    }

    /** * @return void */
    public function hashPasswords(FormEvent $event)
    {
        $form = $event->getForm();

        if (!$form->isRoot()) {
            return;
        }

        if ($form->isValid()) {
            foreach ($this->passwords as $password) {
                $user = $this->getUser($password['form']);

                $this->propertyAccessor->setValue(
                    $user,
                    $password['property_path'],
                    $this->passwordHasher->hashPassword($user$password['password'])
                );
$this->validator = $validator;
        $this->violationMapper = $violationMapper;
    }

    /** * @return void */
    public function validateForm(FormEvent $event)
    {
        $form = $event->getForm();

        if ($form->isRoot()) {
            // Form groups are validated internally (FormValidator). Here we don't set groups as they are retrieved into the validator.             foreach ($this->validator->validate($form) as $violation) {
                // Allow the "invalid" constraint to be put onto                 // non-synchronized forms                 $allowNonSynchronized = $violation->getConstraint() instanceof Form && Form::NOT_SYNCHRONIZED_ERROR === $violation->getCode();

                $this->violationMapper->mapViolation($violation$form$allowNonSynchronized);
            }
        }
    }
}
public function addProfile(self $profile): void
    {
        $this->profiles[] = $profile;
    }

    /** * Returns the duration in microseconds. */
    public function getDuration(): float
    {
        if ($this->isRoot() && $this->profiles) {
            // for the root node with children, duration is the sum of all child durations             $duration = 0;
            foreach ($this->profiles as $profile) {
                $duration += $profile->getDuration();
            }

            return $duration;
        }

        return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
    }

    
return $this->dumpProfile($profile);
    }

    abstract protected function formatTemplate(Profile $profile$prefix): string;

    abstract protected function formatNonTemplate(Profile $profile$prefix): string;

    abstract protected function formatTime(Profile $profile$percent): string;

    private function dumpProfile(Profile $profile$prefix = '', $sibling = false): string
    {
        if ($profile->isRoot()) {
            $this->root = $profile->getDuration();
            $start = $profile->getName();
        } else {
            if ($profile->isTemplate()) {
                $start = $this->formatTemplate($profile$prefix);
            } else {
                $start = $this->formatNonTemplate($profile$prefix);
            }
            $prefix .= $sibling ? '│ ' : ' ';
        }

        
if ($form->isSubmitted() && $form->isSynchronized()) {
            // Validate the form data only if transformation succeeded             $groups = $this->getValidationGroups($form);

            if (!$groups) {
                return;
            }

            $data = $form->getData();
            // Validate the data against its own constraints             $validateDataGraph = $form->isRoot()
                && (\is_object($data) || \is_array($data))
                && (($groups && \is_array($groups)) || ($groups instanceof GroupSequence && $groups->groups))
            ;

            // Validate the data against the constraints defined in the form             /** @var Constraint[] $constraints */
            $constraints = $config->getOption('constraints', []);

            $hasChildren = $form->count() > 0;

            if ($hasChildren && $form->isRoot()) {
                
Home | Imprint | This part of the site doesn't use cookies.