On Symfony's Friends of Symfony User Bundle, I managed to modify a profile action that allows me to view specific user profiles instead of only seeing my own. I basically took the Group Controller's function, and made some code useable for the User Controller, as the Group Controller allows you to view the group, using the name in the URL; now in the User Controller, where profile/ becomes profile/mrxxiv. I'm trying to keep profile/ as well, but the way I have the function set up, it's almost impossible due to Symfony giving me an error, telling me about the empty value in the function, where I'd need to enter a username in order to find & view the user's data.
This is the error when not entering a username in the URL:
Controller "FOS\UserBundle\Controller\ProfileController::showAction()" requires that you provide a value for the "$username" argument (because there is no default value or because there is a non optional argument after this one).
I don't want to enter a default value, I just want to find a way to pass the parameter when it's empty as when I use only the url profile/, I can view my own profile data on the spot. Plus I can't be specific against all users. Disregard the IF statement by the way.
public function showAction($username) {
$user = $this->container->get('security.context')->getToken()->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
throw new AccessDeniedException('This user does not have access to this section.');
}
$user = $this->findUserBy('username', $username);
return $this->container->get('templating')->renderResponse('FOSUserBundle:Profile:show.html.'.$this->container->getParameter('fos_user.template.engine'), array('user' => $user));
}
Wow, this is some Iran, Cuba, China, Russia, North Korea-level citizen surveillance right there, the UK's government has gone totally mad. Power trip indeed, their politicians are totally out of control about this issue. They're starting to cross limits I wouldn't have imagined, to be honest.
British people, fight this, your privacy and freedoms are in danger. Vote this government out of power.
Nintendo unveils The Legend of Zelda: Ocarina of Time remake, and it's out this year by Pulasthi Ariyasinghe
Confirming many rumors, Nintendo officially announced a remake of the classic The Legend of Zelda: Ocarina of Time, the very first game in the series that offered a 3D experience to fans. Unlike previous remasters and re-releases, the originally 1998-released fantasy adventure game is being remade from the ground up for the Nintendo Switch 2 console this time.
"The Nintendo 64 classic returns for a new generation in 2026, reborn exclusively for Nintendo Switch 2," said the company about today's announcement.
While Nintendo didn't go into much detail about the project, other than confirming its existence, we did get a small teaser trailer at the Direct presentation today. Catch the footage below:
With a tapestry as the backdrop, the first half of the trailer tells the tale of Hyrule, the Kokiri forest dwellers, and their fairy companions. It goes onto introduce "one particular boy" without a fairy, which then cuts to a sleeping Link, showcasing what looks like the new art style being introduced in the remake. Unfortunately, no gameplay or a look at the world has been revealed yet.
The game originally released for the Nintendo 64 back in 1998, offering a time travel adventure where Link is once again going up against the evil king Ganondorf. The hugely well-received title has only been playable on modern Nintendo consoles using the Switch Online + Expansion Pack membership.
The Legend of Zelda: Ocarina of Time remake for the Nintendo Switch 2 doesn't have a firm release date yet, but Nintendo says it will be released sometime in 2026. Considering just how many publishers are avoiding the Grand Theft Auto VI release nowadays, the company may copy that strategy and also opt to bring this out before November this year.
Question
Mr.XXIV
On Symfony's Friends of Symfony User Bundle, I managed to modify a profile action that allows me to view specific user profiles instead of only seeing my own. I basically took the Group Controller's function, and made some code useable for the User Controller, as the Group Controller allows you to view the group, using the name in the URL; now in the User Controller, where profile/ becomes profile/mrxxiv. I'm trying to keep profile/ as well, but the way I have the function set up, it's almost impossible due to Symfony giving me an error, telling me about the empty value in the function, where I'd need to enter a username in order to find & view the user's data.
This is the error when not entering a username in the URL:
Controller "FOS\UserBundle\Controller\ProfileController::showAction()" requires that you provide a value for the "$username" argument (because there is no default value or because there is a non optional argument after this one).
I don't want to enter a default value, I just want to find a way to pass the parameter when it's empty as when I use only the url profile/, I can view my own profile data on the spot. Plus I can't be specific against all users. Disregard the IF statement by the way.
public function showAction($username) { $user = $this->container->get('security.context')->getToken()->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } $user = $this->findUserBy('username', $username); return $this->container->get('templating')->renderResponse('FOSUserBundle:Profile:show.html.'.$this->container->getParameter('fos_user.template.engine'), array('user' => $user)); }Link to comment
https://www.neowin.net/forum/topic/1128966-php-function-pass-empty-username-value/Share on other sites
14 answers to this question
Recommended Posts