Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
Next Chapter

Challenge #1 of 1


Q: 

Your colleague asked you to help them fix an error they don't understand:

Error rendering "Alert" component: Expected argument of type "App\Entity\User", "string" given at property path "user".

The component looks like this:

namespace App\Twig\Components;

use App\Entity\User;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent]
class Alert
{
    public User $user;

    // ...
}

And it's rendered in Twig with:

<twig:Alert user="app.user" />

You, as an experienced Symfony developer, noticed the error immediately. How we could fix this?

userVoice