. // }}} /** * Handle network public feed * * @package GNUsocial * @category Controller * * @author Hugo Sales * @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\Controller; use App\Core\DB\DB; use App\Core\Form; use function App\Core\I18n\_m; use App\Entity\Note; use App\Util\Common; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\HttpFoundation\Request; class NetworkPublic extends Controller { public function handle(Request $request) { $form = Form::create([ ['content', TextareaType::class, ['label' => ' ']], ['send', SubmitType::class, ['label' => _m('Send')]], ]); $form->handleRequest($request); if ($form->isSubmitted()) { $data = $form->getData(); if ($form->isValid()) { $content = $data['content']; $id = Common::actor()->getId(); $note = Note::create(['gsactor_id' => $id, 'content' => $content]); DB::persist($note); DB::flush(); } else { // TODO Display error } } $notes = DB::findBy('note', [], ['created' => 'DESC']); return [ '_template' => 'network/public.html.twig', 'post_form' => $form->createView(), 'notes' => $notes, ]; } }