Added an PHP CS fixer config file and applied it to files.

We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
Jan Böhmer 2019-11-09 00:47:20 +01:00
parent 89258bc102
commit e557bdedd5
210 changed files with 2099 additions and 2742 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Form\Part;
@ -38,7 +37,6 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function foo\func;
class OrderdetailType extends AbstractType
{
@ -58,36 +56,35 @@ class OrderdetailType extends AbstractType
$builder->add('supplierpartnr', TextType::class, [
'label' => $this->trans->trans('orderdetails.edit.supplierpartnr'),
'attr' => ['placeholder' => $this->trans->trans('orderdetails.edit.supplierpartnr.placeholder')],
'attr' => ['placeholder' => $this->trans->trans('orderdetails.edit.supplierpartnr.placeholder')],
'required' => false,
'empty_data' => ""
'empty_data' => '',
]);
$builder->add('supplier', StructuralEntityType::class, [
'class' => Supplier::class, 'disable_not_selectable' => true,
'label' => $this->trans->trans('orderdetails.edit.supplier')
'label' => $this->trans->trans('orderdetails.edit.supplier'),
]);
$builder->add('supplier_product_url', UrlType::class, [
'required' => false,
'empty_data' => "",
'label' => $this->trans->trans('orderdetails.edit.url')
'empty_data' => '',
'label' => $this->trans->trans('orderdetails.edit.url'),
]);
$builder->add('obsolete', CheckboxType::class, [
'required' => false,
'label_attr' => ['class' => 'checkbox-custom'],
'label' => $this->trans->trans('orderdetails.edit.obsolete')
'label' => $this->trans->trans('orderdetails.edit.obsolete'),
]);
//Add pricedetails after we know the data, so we can set the default currency
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
/** @var Orderdetail $orderdetail */
$orderdetail = $event->getData();
$dummy_pricedetail = new Pricedetail();
if ($orderdetail !== null && $orderdetail->getSupplier() !== null) {
if (null !== $orderdetail && null !== $orderdetail->getSupplier()) {
$dummy_pricedetail->setCurrency($orderdetail->getSupplier()->getDefaultCurrency());
}
@ -101,10 +98,9 @@ class OrderdetailType extends AbstractType
'by_reference' => false,
'entry_options' => [
'disabled' => !$this->security->isGranted('@parts_prices.edit'),
'measurement_unit' => $options['measurement_unit']
]
'measurement_unit' => $options['measurement_unit'],
],
]);
});
}
@ -118,4 +114,4 @@ class OrderdetailType extends AbstractType
$resolver->setRequired('measurement_unit');
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Form\Part;
@ -29,32 +28,25 @@ use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use App\Entity\Parts\Storelocation;
use App\Entity\PriceInformations\Orderdetail;
use App\Form\AttachmentFormType;
use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityRepository;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\ResetType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function foo\func;
class PartBaseType extends AbstractType
{
@ -75,19 +67,19 @@ class PartBaseType extends AbstractType
$part = $builder->getData();
$status_choices = [
$this->trans->trans("m_status.unknown") => '',
$this->trans->trans('m_status.unknown') => '',
$this->trans->trans('m_status.announced') => 'announced',
$this->trans->trans('m_status.active') => 'active',
$this->trans->trans('m_status.nrfnd') => 'nrfnd',
$this->trans->trans('m_status.eol') => 'eol',
$this->trans->trans('m_status.discontinued') => 'discontinued'
$this->trans->trans('m_status.discontinued') => 'discontinued',
];
//Common section
$builder
->add('name', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('part.edit.name'),
'label' => $this->trans->trans('part.edit.name'),
'attr' => ['placeholder' => $this->trans->trans('part.edit.name.placeholder')],
'disabled' => !$this->security->isGranted('name.edit', $part),
])
@ -97,7 +89,7 @@ class PartBaseType extends AbstractType
'label' => $this->trans->trans('part.edit.description'),
'config_name' => 'description_config',
'attr' => ['placeholder' => $this->trans->trans('part.edit.description.placeholder'), 'rows' => 2],
'disabled' => !$this->security->isGranted('description.edit', $part)
'disabled' => !$this->security->isGranted('description.edit', $part),
])
->add('minAmount', SIUnitType::class, [
'attr' => ['min' => 0, 'placeholder' => $this->trans->trans('part.editmininstock.placeholder')],
@ -121,11 +113,11 @@ class PartBaseType extends AbstractType
->add('tags', TextType::class, [
'required' => false,
'label' => $this->trans->trans('part.edit.tags'),
'empty_data' => "",
'empty_data' => '',
'attr' => [
'class' => 'tagsinput',
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']),],
'disabled' => !$this->security->isGranted('tags.edit', $part)
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
'disabled' => !$this->security->isGranted('tags.edit', $part),
]);
//Manufacturer section
@ -134,7 +126,7 @@ class PartBaseType extends AbstractType
'required' => false,
'label' => $this->trans->trans('part.edit.manufacturer.label'),
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('manufacturer.edit', $part)
'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
])
->add('manufacturer_product_url', UrlType::class, [
'required' => false,
@ -146,12 +138,12 @@ class PartBaseType extends AbstractType
'required' => false,
'empty_data' => '',
'label' => $this->trans->trans('part.edit.mpn'),
'disabled' => !$this->security->isGranted('mpn.edit', $part)])
'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
->add('manufacturing_status', ChoiceType::class, [
'label' => $this->trans->trans('part.edit.manufacturing_status'),
'choices' => $status_choices,
'required' => false,
'disabled' => !$this->security->isGranted('status.edit', $part)
'disabled' => !$this->security->isGranted('status.edit', $part),
]);
//Advanced section
@ -159,35 +151,34 @@ class PartBaseType extends AbstractType
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => $this->trans->trans('part.edit.needs_review'),
'disabled' => !$this->security->isGranted('edit', $part)
'disabled' => !$this->security->isGranted('edit', $part),
])
->add('favorite', CheckboxType::class, [
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => $this->trans->trans('part.edit.is_favorite'),
'disabled' => !$this->security->isGranted('change_favorite', $part)
'disabled' => !$this->security->isGranted('change_favorite', $part),
])
->add('mass', SIUnitType::class, [
'unit' => 'g',
'label' => $this->trans->trans('part.edit.mass'),
'required' => false,
'disabled' => !$this->security->isGranted('mass.edit', $part)
'disabled' => !$this->security->isGranted('mass.edit', $part),
])
->add('partUnit', StructuralEntityType::class, [
'class' => MeasurementUnit::class,
'required' => false,
'disable_not_selectable' => true,
'label' => $this->trans->trans('part.edit.partUnit'),
'disabled' => !$this->security->isGranted('unit.edit', $part)
'disabled' => !$this->security->isGranted('unit.edit', $part),
]);
//Comment section
$builder->add('comment', CKEditorType::class, [
'required' => false,
'label' => $this->trans->trans('part.edit.comment'),
'attr' => ['rows' => 4],
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => ''
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
]);
//Part Lots section
@ -200,7 +191,7 @@ class PartBaseType extends AbstractType
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('lots.edit', $part),
],
'by_reference' => false
'by_reference' => false,
]);
//Attachment section
@ -213,14 +204,14 @@ class PartBaseType extends AbstractType
'data_class' => PartAttachment::class,
'disabled' => !$this->security->isGranted('attachments.edit', $part),
],
'by_reference' => false
'by_reference' => false,
]);
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted('attachments.edit', $part),
'label' => $this->trans->trans('part.edit.master_attachment'),
'entity' => $part
'entity' => $part,
]);
//Orderdetails section
@ -234,7 +225,7 @@ class PartBaseType extends AbstractType
'entry_options' => [
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('orderdetails.edit', $part),
]
],
]);
$builder

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,34 +17,23 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Form\Part;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot;
use App\Entity\Parts\Storelocation;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\Exception;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function GuzzleHttp\Promise\queue;
class PartLotType extends AbstractType
{
@ -62,49 +51,47 @@ class PartLotType extends AbstractType
$builder->add('description', TextType::class, [
'label' => $this->trans->trans('part_lot.edit.description'),
'required' => false,
'empty_data' => "",
'attr' => ['class' => 'form-control-sm']
'empty_data' => '',
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
'label' => $this->trans->trans('part_lot.edit.location'),
'required' => false,
'disable_not_selectable' => true,
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true]
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true],
]);
$builder->add('amount', SIUnitType::class, [
'measurement_unit' => $options['measurement_unit'],
'label' => $this->trans->trans('part_lot.edit.amount'),
'attr' => ['class' => 'form-control-sm']
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('instock_unknown', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('part_lot.edit.instock_unknown'),
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom']
'label_attr' => ['class' => 'checkbox-custom'],
]);
$builder->add('needs_refill', CheckboxType::class, ['label_attr' => ['class' => 'checkbox-custom'],
'label' => $this->trans->trans('part_lot.edit.needs_refill'),
'attr' => ['class' => 'form-control-sm'],
'required' => false
'required' => false,
]);
$builder->add('expirationDate', DateTimeType::class, [
'label' => $this->trans->trans('part_lot.edit.expiration_date'),
'attr' => [],
'required' => false]);
'required' => false, ]);
$builder->add('comment', TextType::class, [
'label' => $this->trans->trans('part_lot.edit.comment'),
'attr' => ['class' => 'form-control-sm'],
'required' => false, 'empty_data' => ""
'required' => false, 'empty_data' => '',
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
@ -114,4 +101,4 @@ class PartLotType extends AbstractType
$resolver->setRequired('measurement_unit');
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
@ -17,55 +17,48 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Form\Part;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\PriceInformations\Currency;
use App\Entity\PriceInformations\Orderdetail;
use App\Entity\PriceInformations\Pricedetail;
use App\Form\Type\CurrencyEntityType;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class PricedetailType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
//No labels needed, we define translation in templates
$builder->add("min_discount_quantity", SIUnitType::class, [
$builder->add('min_discount_quantity', SIUnitType::class, [
'measurement_unit' => $options['measurement_unit'],
'attr' => ['class' => 'form-control-sm']
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add("price_related_quantity", SIUnitType::class, [
$builder->add('price_related_quantity', SIUnitType::class, [
'measurement_unit' => $options['measurement_unit'],
'attr' => ['class' => 'form-control-sm']
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add("price", NumberType::class, [
$builder->add('price', NumberType::class, [
'scale' => 5,
'html5' => true,
'attr' => ['min' => 0, 'step' => "any"]
'attr' => ['min' => 0, 'step' => 'any'],
]);
$builder->add("currency", CurrencyEntityType::class, ['required' => false]);
$builder->add('currency', CurrencyEntityType::class, ['required' => false]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Pricedetail::class,
'error_bubbling' => false
'error_bubbling' => false,
]);
$resolver->setRequired('measurement_unit');
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
}
}
}