Ejemplo n.º 1
0
 /**
  * @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);
 }