. // }}} /** * Handle network public feed * * @package GNUsocial * @category Controller * * @author Hugo Sales * @author Eliseu Amaro * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace App\Controller; // use App\Core\Event; // use App\Util\Common; use App\Core\DB\DB; use App\Core\Form; use function App\Core\I18n\_m; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpFoundation\Request; class UserPanel extends AbstractController { public function __invoke(Request $request) { $prof = Form::create([ [_m('Nickname'), TextType::class], [_m('FullName'), TextType::class], [_m('Homepage'), TextType::class], [_m('Bio'), TextType::class], [_m('Location'), TextType::class], ['save', SubmitType::class, ['label' => _m('Save')]], ]); $prof->handleRequest($request); if ($prof->isSubmitted()) { $data = $prof->getData(); if ($prof->isValid()) { $profile = DB::find('\App\Entity\Profile', ['id' => 2]); foreach (['Nickname', 'FullName', 'Homepage', 'Bio', 'Location'] as $key) { $method = "set{$key}"; $profile->{$method}($data[_m($key)]); } DB::flush(); } else { // Display error } } return $this->render('settings/profile.html.twig', [ 'prof' => $prof->createView(), ]); } }