mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
fix deprecations: getName → getBlockPrefix or nothing
This commit is contained in:
parent
85018f1927
commit
af00cc4da6
@ -27,19 +27,19 @@ use Chill\MainBundle\Entity\Center;
|
|||||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class CenterType extends AbstractType
|
class CenterType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The user linked with this type.
|
* The user linked with this type.
|
||||||
*
|
*
|
||||||
* @var \Chill\MainBundle\Entity\User
|
* @var \Chill\MainBundle\Entity\User
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* associative array where keys are center.id and
|
* associative array where keys are center.id and
|
||||||
* value are center objects
|
* value are center objects
|
||||||
@ -47,14 +47,14 @@ class CenterType extends AbstractType
|
|||||||
* @var Center[]
|
* @var Center[]
|
||||||
*/
|
*/
|
||||||
protected $reachableCenters = array();
|
protected $reachableCenters = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var CenterTransformer
|
* @var CenterTransformer
|
||||||
*/
|
*/
|
||||||
protected $transformer;
|
protected $transformer;
|
||||||
|
|
||||||
public function __construct(TokenStorage $tokenStorage,
|
public function __construct(TokenStorage $tokenStorage,
|
||||||
CenterTransformer $transformer)
|
CenterTransformer $transformer)
|
||||||
{
|
{
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
@ -62,23 +62,18 @@ class CenterType extends AbstractType
|
|||||||
$this->prepareReachableCenterByUser();
|
$this->prepareReachableCenterByUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'center';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a 'hidden' field if only one center is available.
|
* return a 'hidden' field if only one center is available.
|
||||||
*
|
*
|
||||||
* Return a 'choice' field if more than one center is available.
|
* Return a 'choice' field if more than one center is available.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \RuntimeException if the user is not associated with any center
|
* @throws \RuntimeException if the user is not associated with any center
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
$nbReachableCenters = count($this->reachableCenters);
|
$nbReachableCenters = count($this->reachableCenters);
|
||||||
|
|
||||||
if ($nbReachableCenters === 0) {
|
if ($nbReachableCenters === 0) {
|
||||||
throw new \RuntimeException("The user is not associated with "
|
throw new \RuntimeException("The user is not associated with "
|
||||||
. "any center. Associate user with a center");
|
. "any center. Associate user with a center");
|
||||||
@ -88,23 +83,23 @@ class CenterType extends AbstractType
|
|||||||
return 'entity';
|
return 'entity';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* configure default options, i.e. add choices if user can reach multiple
|
* configure default options, i.e. add choices if user can reach multiple
|
||||||
* centers.
|
* centers.
|
||||||
*
|
*
|
||||||
* @param OptionsResolver $resolver
|
* @param OptionsResolver $resolver
|
||||||
*/
|
*/
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
if (count($this->reachableCenters) > 1) {
|
if (count($this->reachableCenters) > 1) {
|
||||||
$resolver->setDefault('class', 'Chill\MainBundle\Entity\Center');
|
$resolver->setDefault('class', 'Chill\MainBundle\Entity\Center');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a data transformer if user can reach only one center
|
* add a data transformer if user can reach only one center
|
||||||
*
|
*
|
||||||
* @param FormBuilderInterface $builder
|
* @param FormBuilderInterface $builder
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*/
|
*/
|
||||||
@ -114,21 +109,21 @@ class CenterType extends AbstractType
|
|||||||
$builder->addModelTransformer($this->transformer);
|
$builder->addModelTransformer($this->transformer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate reachableCenters as an associative array where
|
* populate reachableCenters as an associative array where
|
||||||
* keys are center.id and value are center entities.
|
* keys are center.id and value are center entities.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function prepareReachableCenterByUser()
|
private function prepareReachableCenterByUser()
|
||||||
{
|
{
|
||||||
$groupCenters = $this->user->getGroupCenters();
|
$groupCenters = $this->user->getGroupCenters();
|
||||||
|
|
||||||
foreach ($groupCenters as $groupCenter) {
|
foreach ($groupCenters as $groupCenter) {
|
||||||
|
|
||||||
$center = $groupCenter->getCenter();
|
$center = $groupCenter->getCenter();
|
||||||
|
|
||||||
if (!array_key_exists($center->getId(),
|
if (!array_key_exists($center->getId(),
|
||||||
$this->reachableCenters)) {
|
$this->reachableCenters)) {
|
||||||
$this->reachableCenters[$center->getId()] = $center;
|
$this->reachableCenters[$center->getId()] = $center;
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ use Chill\MainBundle\Entity\PermissionsGroup;
|
|||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class ComposedGroupCenterType extends AbstractType
|
class ComposedGroupCenterType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder->add('permissionsgroup', 'entity', array(
|
$builder->add('permissionsgroup', 'entity', array(
|
||||||
@ -48,13 +48,13 @@ class ComposedGroupCenterType extends AbstractType
|
|||||||
))
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\GroupCenter');
|
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\GroupCenter');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'composed_groupcenter';
|
return 'composed_groupcenter';
|
||||||
}
|
}
|
||||||
|
@ -43,25 +43,25 @@ class ComposedRoleScopeType extends AbstractType
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $roles = array();
|
private $roles = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $rolesWithoutScope = array();
|
private $rolesWithoutScope = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
private $translatableStringHelper;
|
private $translatableStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var RoleProvider
|
* @var RoleProvider
|
||||||
*/
|
*/
|
||||||
private $roleProvider;
|
private $roleProvider;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
RoleProvider $roleProvider
|
RoleProvider $roleProvider
|
||||||
@ -71,19 +71,19 @@ class ComposedRoleScopeType extends AbstractType
|
|||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->roleProvider = $roleProvider;
|
$this->roleProvider = $roleProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
// store values used in internal function
|
// store values used in internal function
|
||||||
$translatableStringHelper = $this->translatableStringHelper;
|
$translatableStringHelper = $this->translatableStringHelper;
|
||||||
$rolesWithoutScopes = $this->rolesWithoutScope;
|
$rolesWithoutScopes = $this->rolesWithoutScope;
|
||||||
|
|
||||||
//build roles
|
//build roles
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($this->roles as $role) {
|
foreach ($this->roles as $role) {
|
||||||
$values[$role] = $role;
|
$values[$role] = $role;
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('role', 'choice', array(
|
->add('role', 'choice', array(
|
||||||
'choices' => $values,
|
'choices' => $values,
|
||||||
@ -107,14 +107,9 @@ class ComposedRoleScopeType extends AbstractType
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
'data' => null
|
'data' => null
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return 'composed_role_scope';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\RoleScope');
|
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\RoleScope');
|
||||||
|
@ -30,16 +30,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
*/
|
*/
|
||||||
class Select2ChoiceType extends AbstractType
|
class Select2ChoiceType extends AbstractType
|
||||||
{
|
{
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'select2_choice';
|
return 'select2_choice';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return 'choice';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults(
|
$resolver->setDefaults(
|
||||||
|
@ -44,14 +44,14 @@ class Select2CountryType extends AbstractType
|
|||||||
* @var ObjectManager
|
* @var ObjectManager
|
||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
|
|
||||||
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'select2_chill_country';
|
return 'select2_chill_country';
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ class Select2CountryType extends AbstractType
|
|||||||
{
|
{
|
||||||
return 'select2_choice';
|
return 'select2_choice';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||||
{
|
{
|
||||||
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||||
|
@ -30,16 +30,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
*/
|
*/
|
||||||
class Select2EntityType extends AbstractType
|
class Select2EntityType extends AbstractType
|
||||||
{
|
{
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'select2_entity';
|
return 'select2_entity';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'entity';
|
return 'entity';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->replaceDefaults(
|
$resolver->replaceDefaults(
|
||||||
|
@ -41,18 +41,18 @@ class Select2LanguageType extends AbstractType
|
|||||||
* @var ObjectManager
|
* @var ObjectManager
|
||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
|
|
||||||
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
public function __construct(RequestStack $requestStack,ObjectManager $em)
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'select2_chill_language';
|
return 'select2_chill_language';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$transformer = new MultipleObjectsToIdTransformer($this->em,'Chill\MainBundle\Entity\Language');
|
$transformer = new MultipleObjectsToIdTransformer($this->em,'Chill\MainBundle\Entity\Language');
|
||||||
@ -63,7 +63,7 @@ class Select2LanguageType extends AbstractType
|
|||||||
{
|
{
|
||||||
return 'select2_choice';
|
return 'select2_choice';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||||
{
|
{
|
||||||
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||||
@ -81,4 +81,4 @@ class Select2LanguageType extends AbstractType
|
|||||||
'choices' => $choices
|
'choices' => $choices
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ class TranslatableStringFormType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options) {
|
public function buildForm(FormBuilderInterface $builder, array $options) {
|
||||||
foreach ($this->availableLanguages as $lang) {
|
foreach ($this->availableLanguages as $lang) {
|
||||||
$builder->add($lang, 'text',
|
$builder->add($lang, 'text',
|
||||||
array('required' => (in_array($lang,
|
array('required' => (in_array($lang,
|
||||||
$this->frameworkTranslatorFallback))));
|
$this->frameworkTranslatorFallback))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'translatable_string';
|
return 'translatable_string';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user