Commit 8445e81d authored by Julien Fastré's avatar Julien Fastré
Browse files

refactor: move scope field to trait

[ci skip] as we know tests are failing
parent 7cf41d9c
......@@ -21,12 +21,54 @@
namespace Chill\ReportBundle\Form;
use Chill\MainBundle\Form\Type\AbstractHasScopeType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
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 array $options
......@@ -42,16 +84,17 @@ class ReportType extends AbstractHasScopeType
'group' => $options['cFGroup']))
;
$this->appendScopeChoices($builder, $options);
$this->appendScopeChoices($builder, $options['role'], $options['center'],
$this->user, $this->authorizationHelper,
$this->translatableStringHelper,
$this->om);
}
/**
* @param OptionsResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
{
$resolver->setDefaults(array(
'data_class' => 'Chill\ReportBundle\Entity\Report'
));
......@@ -63,6 +106,8 @@ class ReportType extends AbstractHasScopeType
$resolver->setAllowedTypes(array(
'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup',
));
$this->appendScopeChoicesOptions($resolver);
}
/**
......
......@@ -33,6 +33,7 @@ services:
- "@chill.main.security.authorization.helper"
- "@security.token_storage"
- "@chill.main.helper.translatable_string"
- "@doctrine.orm.entity_manager"
tags:
- { name: form.type, alias: chill_reportbundle_report }
\ No newline at end of file
......@@ -30,8 +30,8 @@
<dl>
<dt class="inline">{{ 'Person'|trans }}</dt>
<dd>{{ entity.person }}</dd>
<!-- <dt class="inline">{{ 'Scope'|trans }}</dt>
<dd>{{ entity.scope }}</dd> -->
<dt class="inline">{{ 'Scope'|trans }}</dt>
<dd><span class="scope">{{ entity.scope.name|localize_translatable_string }}</span></dd>
<dt class="inline">{{ 'Date'|trans }}</dt>
<dd>{{ entity.date|localizeddate('long', 'none') }}</dd>
<dt class="inline">{{ 'User'|trans }}</dt>
......
Supports Markdown
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