/** * @Route("/editor", name="area_profile_editor") */ public function editorAction(Request $request) { $this->breadcrumbs()->entryLink($this->trans('Profile editor', [], 'pages'), 'area_profile_editor', ['slug' => $this->getSlug()]); $area = $this->getMembership()->getItem(); $repo = $this->get(self::REPOSITORY); $territoryRepo = $this->get('cantiga.core.repo.project_territory'); $territoryRepo->setProject($area->getProject()); $formModel = $this->extensionPointFromSettings(CoreExtensions::AREA_FORM, CoreSettings::AREA_FORM); $text = $this->getTextRepository()->getTextOrFalse(CoreTexts::AREA_PROFILE_EDITOR_TEXT, $request, $this->getActiveProject()); $intent = new AreaProfileIntent($area, $repo); $action = new FormAction($intent, AreaProfileForm::class, ['projectSettings' => $this->getProjectSettings(), 'customFormModel' => $formModel, 'territoryRepository' => $territoryRepo]); $action->slug($this->getSlug()); return $action->action($this->generateUrl('area_profile_editor', ['slug' => $this->getSlug()]))->template('CantigaCoreBundle:AreaProfile:editor.html.twig')->redirect($this->generateUrl('area_profile_editor', ['slug' => $this->getSlug()]))->formSubmittedMessage('AreaProfileSaved')->set('progressBarColor', $area->getPercentCompleteness() < 50 ? 'red' : ($area->getPercentCompleteness() < 80 ? 'orange' : 'green'))->set('percentCompleteness', $area->getPercentCompleteness())->set('text', $text)->customForm($formModel)->onSubmit(function (AreaProfileIntent $intent) use($repo) { $intent->execute(); })->run($this, $request); }
/** * @Route("/manage-photo", name="user_profile_photo") */ public function photoAction(Request $request) { $this->breadcrumbs()->entryLink($this->trans('Manage photo', [], 'pages'), 'user_profile_photo'); $repo = $this->get(self::REPOSITORY); $intent = new UserProfilePhotoIntent($this->getUser(), $repo, $this->get('kernel')->getRootDir() . '/../web/ph'); $action = new FormAction($intent, UserPhotoUploadForm::class); return $action->action($this->generateUrl('user_profile_photo'))->template('CantigaCoreBundle:UserProfile:photo.html.twig')->redirect($this->generateUrl('user_profile_photo'))->formSubmittedMessage('The new image has been set up.')->onSubmit(function (UserProfilePhotoIntent $intent) use($repo) { $intent->execute(); })->run($this, $request); }