Commit 300450bc by Yvon

comment and remove useless custom form_theme block

parent 7d03333f
......@@ -136,14 +136,31 @@ class IndexController extends AbstractController
]);
}
/**
* This method is core method to guide the new
* prestataire when using presta_self_init_and_eval mode.
* It is basically a state machine that returns the appropriate
* route path depending on current state (details in the body).
* It also provides the prestataire object itself for convenience
* (not so easy to fetch from user when prestataire is disabled).
* @param $origin
* @return array|null[]
*/
private function getAndDispatchPrestataire($origin)
{
/*
* Go to home page if process is not active or if user is not connected as adherent.
* Second filter is just an easy way to early detect anonymous users.
* Why adherent ? Because once prestataire is created disabled and after is has been linked
* to some user, this user will connect to the platform as an adherent (because prestataire is disabled).
*/
if (!$this->getParameter('presta_self_init_and_eval')
|| !$this->security->isGranted('ROLE_ADHERENT')) { //not sure ROLE_ADHERENT is the proper check here
$destination = 'index';
return $destination !== $origin ? [$destination, null] : [null, null];
}
//Fetch the prestataire even when it is disabled
/* @var ArrayCollection $prestas */
if ($this->em->getFilters()->isEnabled('enabled_filter')) {
$this->em->getFilters()->disable('enabled_filter');
......@@ -161,21 +178,28 @@ class IndexController extends AbstractController
/* @var Prestataire $presta */
$presta = $prestas[0];
//Go to home page if the prestataire is enabled
if ($presta->isEnabled()) {
$destination = 'index';
return $destination !== $origin ? [$destination, $presta] : [null, $presta];
}
//Go to "all forms already sent, please just wait now" page if questionnaire has been submitted already
if ($presta->getSelfEvalPrestaQuiz()) {
$destination = 'prestaquiz-sent';
return $destination !== $origin ? [$destination, $presta] : [null, $presta];
}
//Go to questionnaire if first identification form has been submitted
//Condition is detected using market_channel_function attributes which is
//set in the first form (it is also the only mandatory attribute to start
//the self-eval part)
if ($presta->getMarketChannelFunction()) {
$destination = 'prestaquiz-selfeval';
return $destination !== $origin ? [$destination, $presta] : [null, $presta];
}
//In other cases, start the subscription process
$destination = 'prestaquiz-infos';
return $destination !== $origin ? [$destination, $presta] : [null, $presta];
}
......
......@@ -12,6 +12,9 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotNull;
/**
* Identification questionnaire for prestataire.
*/
class InfosPrestaQuizType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
......
......@@ -11,6 +11,12 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotNull;
/**
*
* Self-eval prestataire questionnaire base class
* containing useful attributes and buildForm for
* sections that are common to distributors and producers
*/
class SelfEvalPrestaQuizType extends AbstractType
{
protected array $stdChoices;
......
{% extends '@kohinos/common/layout.html.twig' %}
{% block content %}
{# Form theme use is mandatory to insert non-text stuff (such as html, icons...) in the choice type choices label. #}
{% form_theme form '@kohinos/tav/prestaquiz_form_theme.html.twig' %}
<h1>Inscription point de vente (2/2) : auto-évaluation</h1>
{{ form_start(form) }}
{# includes twig common to distributors and producers #}
{% include '@kohinos/tav/selfeval_prestaquiz.html.twig' %}
......
{% block form_label -%}
{% if label is not same as(false) -%}
{%- if compound is defined and compound -%}
{%- set element = 'legend' -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
{%- else -%}
{%- set label_attr = label_attr|merge({for: id}) -%}
{%- endif -%}
{% if required -%}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
{%- endif -%}
{% if label is empty -%}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{%- endif -%}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
{%- else -%}
{%- if errors|length > 0 -%}
<div id="{{ id }}_errors" class="mb-2">
{{- form_errors(form) -}}
</div>
{%- endif -%}
{%- endif -%}
{%- endblock form_label %}
{# Custom form theme based on file : Resources/views/Form/bootstrap_4_layout.html.twig
where unique change is use of filter |raw on line
{{- label is not same as(false) ? (translation_domain is same as(false) ? label|raw : label|trans(label_translation_parameters, translation_domain))|raw -}}
This is to allow use of html in choice type choices label,
as suggested here : https://stackoverflow.com/questions/45562135/html-in-label-choice-form
#}
{% block checkbox_radio_label -%}
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#}
......
{% extends '@kohinos/common/layout.html.twig' %}
{% block content %}
{# Form theme use is mandatory to insert non-text stuff (such as html, icons...) in the choice type choices label. #}
{% form_theme form '@kohinos/tav/prestaquiz_form_theme.html.twig' %}
<h1>Inscription point de vente (2/2) : auto-évaluation</h1>
{{ form_start(form) }}
{# includes twig common to distributors and producers #}
{% include '@kohinos/tav/selfeval_prestaquiz.html.twig' %}
<br/>
......
{# View for prestataire questionnaire sections that are common to distributors and producers #}
<br/>
<h2><i class="fas fa-universal-access"></i> Accessibilité et Inclusivité</h2>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment