how can i get the id of the logged in user?? i use symfony 7

i want to get the userid of the logged in user so it gets linked with the review in the database as they have one to one relationship

class ReviewFormType extends AbstractType
{
    
    public function buildForm(FormBuilderInterface $builder, array $options):void
    {

        $builder
            ->add('content')
        ->add('userId', HiddenType::class);

    }
    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Review::class,

        ]);
    }

}

Leave a Comment