mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 22:34:24 +00:00
refactor: move scope field to trait
[ci skip] as we know tests are failing
This commit is contained in:
parent
7cf41d9c9d
commit
8445e81d44
@ -21,12 +21,54 @@
|
|||||||
|
|
||||||
namespace Chill\ReportBundle\Form;
|
namespace Chill\ReportBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\AbstractHasScopeType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
|
||||||
class ReportType extends AbstractHasScopeType
|
class ReportType extends AbstractType
|
||||||
{
|
{
|
||||||
|
use AppendScopeChoiceTypeTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var AuthorizationHelper
|
||||||
|
*/
|
||||||
|
protected $authorizationHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Doctrine\Common\Persistence\ObjectManager
|
||||||
|
*/
|
||||||
|
protected $om;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Chill\MainBundle\Entity\User
|
||||||
|
*/
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
public function __construct(AuthorizationHelper $helper,
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
|
ObjectManager $om)
|
||||||
|
{
|
||||||
|
$this->authorizationHelper = $helper;
|
||||||
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->om = $om;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FormBuilderInterface $builder
|
* @param FormBuilderInterface $builder
|
||||||
* @param array $options
|
* @param array $options
|
||||||
@ -42,7 +84,10 @@ class ReportType extends AbstractHasScopeType
|
|||||||
'group' => $options['cFGroup']))
|
'group' => $options['cFGroup']))
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->appendScopeChoices($builder, $options);
|
$this->appendScopeChoices($builder, $options['role'], $options['center'],
|
||||||
|
$this->user, $this->authorizationHelper,
|
||||||
|
$this->translatableStringHelper,
|
||||||
|
$this->om);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +95,6 @@ class ReportType extends AbstractHasScopeType
|
|||||||
*/
|
*/
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
parent::configureOptions($resolver);
|
|
||||||
|
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\ReportBundle\Entity\Report'
|
'data_class' => 'Chill\ReportBundle\Entity\Report'
|
||||||
));
|
));
|
||||||
@ -63,6 +106,8 @@ class ReportType extends AbstractHasScopeType
|
|||||||
$resolver->setAllowedTypes(array(
|
$resolver->setAllowedTypes(array(
|
||||||
'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup',
|
'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->appendScopeChoicesOptions($resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,6 +33,7 @@ services:
|
|||||||
- "@chill.main.security.authorization.helper"
|
- "@chill.main.security.authorization.helper"
|
||||||
- "@security.token_storage"
|
- "@security.token_storage"
|
||||||
- "@chill.main.helper.translatable_string"
|
- "@chill.main.helper.translatable_string"
|
||||||
|
- "@doctrine.orm.entity_manager"
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type, alias: chill_reportbundle_report }
|
- { name: form.type, alias: chill_reportbundle_report }
|
||||||
|
|
@ -30,8 +30,8 @@
|
|||||||
<dl>
|
<dl>
|
||||||
<dt class="inline">{{ 'Person'|trans }}</dt>
|
<dt class="inline">{{ 'Person'|trans }}</dt>
|
||||||
<dd>{{ entity.person }}</dd>
|
<dd>{{ entity.person }}</dd>
|
||||||
<!-- <dt class="inline">{{ 'Scope'|trans }}</dt>
|
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
||||||
<dd>{{ entity.scope }}</dd> -->
|
<dd><span class="scope">{{ entity.scope.name|localize_translatable_string }}</span></dd>
|
||||||
<dt class="inline">{{ 'Date'|trans }}</dt>
|
<dt class="inline">{{ 'Date'|trans }}</dt>
|
||||||
<dd>{{ entity.date|localizeddate('long', 'none') }}</dd>
|
<dd>{{ entity.date|localizeddate('long', 'none') }}</dd>
|
||||||
<dt class="inline">{{ 'User'|trans }}</dt>
|
<dt class="inline">{{ 'User'|trans }}</dt>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user