cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,73 +1,72 @@
<?php
namespace Chill\DocStoreBundle\Form;
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Form;
use Chill\DocStoreBundle\Entity\Document;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\Persistence\ObjectManager;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
class AccompanyingCourseDocumentType extends AbstractType
{
/**
* the user running this form
*
* @var User
*/
protected $user;
/**
*
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
*
* @var ObjectManager
*/
protected $om;
/**
*
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
/**
* the user running this form.
*
* @var User
*/
protected $user;
public function __construct(
TranslatableStringHelper $translatableStringHelper
)
{
) {
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class)
->add('description', ChillTextareaType::class, [
'required' => false
'required' => false,
])
->add('object', StoredObjectType::class, [
'error_bubbling' => true
'error_bubbling' => true,
])
->add('date', ChillDateType::class)
//TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none...
->add('category', EntityType::class, array(
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory',
'query_builder' => function (EntityRepository $er) {
@@ -78,9 +77,7 @@ class AccompanyingCourseDocumentType extends AbstractType
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
))
;
]);
}
public function configureOptions(OptionsResolver $resolver)
@@ -88,7 +85,7 @@ class AccompanyingCourseDocumentType extends AbstractType
$resolver->setDefaults([
'data_class' => Document::class,
]);
// $resolver->setRequired(['role', 'center'])
// ->setAllowedTypes('role', [ \Symfony\Component\Security\Core\Role\Role::class ])
// ->setAllowedTypes('center', [ \Chill\MainBundle\Entity\Center::class ])

View File

@@ -1,13 +1,20 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Form;
use Chill\DocStoreBundle\Entity\DocumentCategory;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DocumentCategoryType extends AbstractType
{
@@ -17,28 +24,26 @@ class DocumentCategoryType extends AbstractType
{
// TODO faire un service dans CHillMain
foreach ($kernelBundles as $key => $value) {
if(substr($key, 0, 5) === 'Chill') {
if (substr($key, 0, 5) === 'Chill') {
$this->chillBundlesFlipped[$value] = $key;
}
}
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('bundleId', ChoiceType::class, array(
->add('bundleId', ChoiceType::class, [
'choices' => $this->chillBundlesFlipped,
'disabled' => true,
))
->add('idInsideBundle', null, array(
])
->add('idInsideBundle', null, [
'disabled' => true,
))
->add('documentClass', null, array(
])
->add('documentClass', null, [
'disabled' => true,
)) // cahcerh par default PersonDocument
->add('name', TranslatableStringFormType::class)
;
]) // cahcerh par default PersonDocument
->add('name', TranslatableStringFormType::class);
}
public function configureOptions(OptionsResolver $resolver)

View File

@@ -1,76 +1,76 @@
<?php
namespace Chill\DocStoreBundle\Form;
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Form;
use Chill\DocStoreBundle\Entity\Document;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\Persistence\ObjectManager;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
class PersonDocumentType extends AbstractType
{
/**
* the user running this form
*
* @var User
*/
protected $user;
/**
*
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
*
* @var ObjectManager
*/
protected $om;
/**
*
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
/**
* the user running this form.
*
* @var User
*/
protected $user;
public function __construct(
TranslatableStringHelper $translatableStringHelper
)
{
) {
$this->translatableStringHelper = $translatableStringHelper;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class)
->add('description', ChillTextareaType::class, [
'required' => false
'required' => false,
])
->add('object', StoredObjectType::class, [
'error_bubbling' => true
'error_bubbling' => true,
])
->add('scope', ScopePickerType::class, [
'center' => $options['center'],
'role' => $options['role']
'role' => $options['role'],
])
->add('date', ChillDateType::class)
->add('category', EntityType::class, array(
->add('category', EntityType::class, [
'placeholder' => 'Choose a document category',
'class' => 'ChillDocStoreBundle:DocumentCategory',
'query_builder' => function (EntityRepository $er) {
@@ -81,9 +81,7 @@ class PersonDocumentType extends AbstractType
'choice_label' => function ($entity = null) {
return $entity ? $this->translatableStringHelper->localize($entity->getName()) : '';
},
))
;
]);
}
public function configureOptions(OptionsResolver $resolver)
@@ -91,10 +89,9 @@ class PersonDocumentType extends AbstractType
$resolver->setDefaults([
'data_class' => Document::class,
]);
$resolver->setRequired(['role', 'center'])
->setAllowedTypes('role', [ \Symfony\Component\Security\Core\Role\Role::class ])
->setAllowedTypes('center', [ \Chill\MainBundle\Entity\Center::class ])
;
->setAllowedTypes('role', [\Symfony\Component\Security\Core\Role\Role::class])
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]);
}
}

View File

@@ -1,108 +1,115 @@
<?php
/*
*/
namespace Chill\DocStoreBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use ChampsLibres\AsyncUploaderBundle\Form\Type\AsyncUploaderType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\DocStoreBundle\Entity\StoredObject;
use Symfony\Component\Form\CallbackTransformer;
use Doctrine\ORM\EntityManagerInterface;
/**
* Form type which allow to join a document
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Form;
use ChampsLibres\AsyncUploaderBundle\Form\Type\AsyncUploaderType;
use Chill\DocStoreBundle\Entity\StoredObject;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function json_decode;
use function json_encode;
/**
* Form type which allow to join a document.
*/
class StoredObjectType extends AbstractType
{
/**
*
* @var EntityManagerInterface
*/
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('filename', AsyncUploaderType::class)
->add('type', HiddenType::class)
->add('keyInfos', HiddenType::class)
->add('iv', HiddenType::class)
;
->add('iv', HiddenType::class);
$builder
->get('keyInfos')
->addModelTransformer(new CallbackTransformer(
[$this, 'transform'], [$this, 'reverseTransform']
));
[$this, 'transform'],
[$this, 'reverseTransform']
));
$builder
->get('iv')
->addModelTransformer(new CallbackTransformer(
[$this, 'transform'], [$this, 'reverseTransform']
));
[$this, 'transform'],
[$this, 'reverseTransform']
));
$builder
->addModelTransformer(new CallbackTransformer(
[ $this, 'transformObject'], [$this, 'reverseTransformObject']
));
[$this, 'transformObject'],
[$this, 'reverseTransformObject']
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('data_class', StoredObject::class);
}
public function getBlockPrefix()
{
return 'stored_object';
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('data_class', StoredObject::class)
;
}
public function reverseTransform($value)
{
if ($value === null) {
if (null === $value) {
return null;
}
return \json_decode($value, true);
return json_decode($value, true);
}
public function reverseTransformObject($object)
{
if (null === $object) {
return null;
}
if (null === $object->getFilename()) {
// remove the original object
$this->em->remove($object);
return null;
}
return $object;
}
public function transform($object)
{
if ($object === null) {
if (null === $object) {
return null;
}
return \json_encode($object);
return json_encode($object);
}
public function transformObject($object = null)
{
return $object;
}
public function reverseTransformObject($object)
{
if (NULL === $object) {
return null;
}
if (NULL === $object->getFilename()) {
// remove the original object
$this->em->remove($object);
return null;
}
return $object;
}
}