mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 19:28:51 +02:00
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:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -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,16 +17,12 @@
|
|||
* 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\DataTables;
|
||||
|
||||
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\FootprintAttachment;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
|
@ -41,7 +37,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class AttachmentDataTable implements DataTableTypeInterface
|
||||
{
|
||||
|
||||
protected $translator;
|
||||
protected $entityURLGenerator;
|
||||
protected $attachmentHelper;
|
||||
|
@ -69,10 +64,6 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
//->leftJoin('attachment.element', 'element');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataTable $dataTable
|
||||
* @param array $options
|
||||
*/
|
||||
public function configure(DataTable $dataTable, array $options)
|
||||
{
|
||||
$dataTable->add('picture', TextColumn::class, [
|
||||
|
@ -91,7 +82,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('name', TextColumn::class, [
|
||||
|
@ -115,7 +106,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('attachment_type', TextColumn::class, [
|
||||
|
@ -126,7 +117,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
$this->entityURLGenerator->editURL($context->getAttachmentType()),
|
||||
htmlspecialchars($value)
|
||||
);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('element', TextColumn::class, [
|
||||
|
@ -138,11 +129,11 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
$this->entityURLGenerator->infoURL($context->getElement()),
|
||||
$this->elementTypeNameGenerator->getTypeNameCombination($context->getElement(), true)
|
||||
);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable->add('filename', TextColumn::class, [
|
||||
'propertyPath' => 'filename'
|
||||
'propertyPath' => 'filename',
|
||||
]);
|
||||
|
||||
$dataTable->add('filesize', TextColumn::class, [
|
||||
|
@ -151,7 +142,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
return $this->attachmentHelper->getHumanFileSize($context);
|
||||
}
|
||||
if ($context->isExternal()) {
|
||||
return '<i>' . $this->translator->trans('attachment.external') . '</i>';
|
||||
return '<i>'.$this->translator->trans('attachment.external').'</i>';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
|
@ -160,17 +151,17 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
</span>',
|
||||
$this->translator->trans('attachment.file_not_found')
|
||||
);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$dataTable
|
||||
->add('addedDate', LocaleDateTimeColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.addedDate'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('lastModified', LocaleDateTimeColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.lastModified'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
]);
|
||||
|
||||
$dataTable->add('show_in_table', BoolColumn::class, [
|
||||
|
@ -178,7 +169,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
'trueValue' => $this->translator->trans('true'),
|
||||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
]);
|
||||
|
||||
$dataTable->add('isPicture', BoolColumn::class, [
|
||||
|
@ -187,7 +178,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false,
|
||||
'propertyPath' => 'picture'
|
||||
'propertyPath' => 'picture',
|
||||
]);
|
||||
|
||||
$dataTable->add('is3DModel', BoolColumn::class, [
|
||||
|
@ -196,7 +187,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false,
|
||||
'propertyPath' => '3dmodel'
|
||||
'propertyPath' => '3dmodel',
|
||||
]);
|
||||
|
||||
$dataTable->add('isBuiltin', BoolColumn::class, [
|
||||
|
@ -205,7 +196,7 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false,
|
||||
'propertyPath' => 'builtin'
|
||||
'propertyPath' => 'builtin',
|
||||
]);
|
||||
|
||||
$dataTable->createAdapter(ORMAdapter::class, [
|
||||
|
@ -215,4 +206,4 @@ class AttachmentDataTable implements DataTableTypeInterface
|
|||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,12 +17,10 @@
|
|||
* 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\DataTables\Column;
|
||||
|
||||
|
||||
use App\Entity\Base\DBElement;
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\Parts\Part;
|
||||
|
@ -34,7 +32,6 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
|||
|
||||
class EntityColumn extends AbstractColumn
|
||||
{
|
||||
|
||||
protected $urlGenerator;
|
||||
protected $accessor;
|
||||
|
||||
|
@ -48,11 +45,12 @@ class EntityColumn extends AbstractColumn
|
|||
* The normalize function is responsible for converting parsed and processed data to a datatables-appropriate type.
|
||||
*
|
||||
* @param mixed $value The single value of the column
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function normalize($value)
|
||||
{
|
||||
/** @var NamedDBElement $value */
|
||||
/* @var NamedDBElement $value */
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -63,7 +61,7 @@ class EntityColumn extends AbstractColumn
|
|||
$resolver->setRequired('property');
|
||||
|
||||
$resolver->setDefault('field', function (Options $option) {
|
||||
return $option['property'] . '.name';
|
||||
return $option['property'].'.name';
|
||||
});
|
||||
|
||||
$resolver->setDefault('render', function (Options $options) {
|
||||
|
@ -72,7 +70,7 @@ class EntityColumn extends AbstractColumn
|
|||
$entity = $this->accessor->getValue($context, $options['property']);
|
||||
|
||||
if ($entity) {
|
||||
if ($entity->getID() !== null) {
|
||||
if (null !== $entity->getID()) {
|
||||
return sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$this->urlGenerator->listPartsURL($entity),
|
||||
|
@ -85,4 +83,4 @@ class EntityColumn extends AbstractColumn
|
|||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,12 +17,10 @@
|
|||
* 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\DataTables\Column;
|
||||
|
||||
|
||||
use IntlDateFormatter;
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
@ -30,7 +28,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
/**
|
||||
* Similar to the built in DateTimeColumn, but the datetime is formatted using a IntlDateFormatter,
|
||||
* to get prettier locale based formatting.
|
||||
* @package App\DataTables\Column
|
||||
*/
|
||||
class LocaleDateTimeColumn extends AbstractColumn
|
||||
{
|
||||
|
@ -45,13 +42,13 @@ class LocaleDateTimeColumn extends AbstractColumn
|
|||
$value = new \DateTime((string) $value);
|
||||
}
|
||||
|
||||
$formatValues = array(
|
||||
$formatValues = [
|
||||
'none' => IntlDateFormatter::NONE,
|
||||
'short' => IntlDateFormatter::SHORT,
|
||||
'medium' => IntlDateFormatter::MEDIUM,
|
||||
'long' => IntlDateFormatter::LONG,
|
||||
'full' => IntlDateFormatter::FULL,
|
||||
);
|
||||
];
|
||||
|
||||
$formatter = IntlDateFormatter::create(
|
||||
\Locale::getDefault(),
|
||||
|
@ -74,11 +71,11 @@ class LocaleDateTimeColumn extends AbstractColumn
|
|||
->setDefaults([
|
||||
'dateFormat' => 'short',
|
||||
'timeFormat' => 'short',
|
||||
'nullValue' => ''
|
||||
'nullValue' => '',
|
||||
])
|
||||
->setAllowedTypes('nullValue', 'string')
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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\DataTables;
|
||||
|
@ -28,25 +27,21 @@ use App\Entity\Parts\Category;
|
|||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Services\AmountFormatter;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\Attachments\PartPreviewGenerator;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use App\Services\ToolsTreeBuilder;
|
||||
use App\Services\TreeBuilder;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
|
||||
use Omines\DataTablesBundle\Column\BoolColumn;
|
||||
use Omines\DataTablesBundle\Column\DateTimeColumn;
|
||||
use Omines\DataTablesBundle\Column\MapColumn;
|
||||
use Omines\DataTablesBundle\Column\TextColumn;
|
||||
use Omines\DataTablesBundle\DataTable;
|
||||
use Omines\DataTablesBundle\DataTableTypeInterface;
|
||||
use SebastianBergmann\CodeCoverage\Report\Text;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class PartsDataTable implements DataTableTypeInterface
|
||||
|
@ -134,19 +129,15 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
}
|
||||
|
||||
if (isset($options['tag'])) {
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%' . $options['tag'] . '%');
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%');
|
||||
}
|
||||
|
||||
if (isset($options['search'])) {
|
||||
$builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search')
|
||||
->setParameter('search', '%' . $options['search'] . '%');
|
||||
->setParameter('search', '%'.$options['search'].'%');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataTable $dataTable
|
||||
* @param array $options
|
||||
*/
|
||||
public function configure(DataTable $dataTable, array $options)
|
||||
{
|
||||
$dataTable
|
||||
|
@ -154,7 +145,7 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
'label' => '',
|
||||
'render' => function ($value, Part $context) {
|
||||
$preview_attachment = $this->previewGenerator->getTablePreviewAttachment($context);
|
||||
if ($preview_attachment === null) {
|
||||
if (null === $preview_attachment) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -165,7 +156,7 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
$this->attachmentURLGenerator->getThumbnailURL($preview_attachment, 'thumbnail_md'),
|
||||
'img-fluid hoverpic'
|
||||
);
|
||||
}
|
||||
},
|
||||
])
|
||||
->add('name', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.name'),
|
||||
|
@ -179,7 +170,7 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
])
|
||||
->add('id', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.id'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('description', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.description'),
|
||||
|
@ -190,19 +181,19 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
])
|
||||
->add('footprint', EntityColumn::class, [
|
||||
'property' => 'footprint',
|
||||
'label' => $this->translator->trans('part.table.footprint')
|
||||
'label' => $this->translator->trans('part.table.footprint'),
|
||||
])
|
||||
->add('manufacturer', EntityColumn::class, [
|
||||
'property' => 'manufacturer',
|
||||
'label' => $this->translator->trans('part.table.manufacturer')
|
||||
'label' => $this->translator->trans('part.table.manufacturer'),
|
||||
])
|
||||
->add('storelocation', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.storeLocations'),
|
||||
'render' => function ($value, Part $context) {
|
||||
$tmp = array();
|
||||
$tmp = [];
|
||||
foreach ($context->getPartLots() as $lot) {
|
||||
//Ignore lots without storelocation
|
||||
if ($lot->getStorageLocation() === null) {
|
||||
if (null === $lot->getStorageLocation()) {
|
||||
continue;
|
||||
}
|
||||
$tmp[] = sprintf(
|
||||
|
@ -210,51 +201,52 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
$this->urlGenerator->listPartsURL($lot->getStorageLocation()),
|
||||
$lot->getStorageLocation()->getName()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return implode('<br>', $tmp);
|
||||
}
|
||||
},
|
||||
])
|
||||
->add('amount', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.amount'),
|
||||
'render' => function ($value, Part $context) {
|
||||
$amount = $context->getAmountSum();
|
||||
|
||||
return $this->amountFormatter->format($amount, $context->getPartUnit());
|
||||
}
|
||||
},
|
||||
])
|
||||
->add('minamount', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.minamount'),
|
||||
'visible' => false,
|
||||
'render' => function ($value, Part $context) {
|
||||
return $this->amountFormatter->format($value, $context->getPartUnit());
|
||||
}
|
||||
},
|
||||
])
|
||||
->add('partUnit', TextColumn::class, [
|
||||
'field' => 'partUnit.name',
|
||||
'label' => $this->translator->trans('part.table.partUnit'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('addedDate', LocaleDateTimeColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.addedDate'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('lastModified', LocaleDateTimeColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.lastModified'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('needs_review', BoolColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.needsReview'),
|
||||
'trueValue' => $this->translator->trans('true'),
|
||||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('favorite', BoolColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.favorite'),
|
||||
'trueValue' => $this->translator->trans('true'),
|
||||
'falseValue' => $this->translator->trans('false'),
|
||||
'nullValue' => '',
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('manufacturing_status', MapColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.manufacturingStatus'),
|
||||
|
@ -266,25 +258,25 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
'active' => $this->translator->trans('m_status.active'),
|
||||
'nrfnd' => $this->translator->trans('m_status.nrfnd'),
|
||||
'eol' => $this->translator->trans('m_status.eol'),
|
||||
'discontinued' => $this->translator->trans('m_status.discontinued')
|
||||
]
|
||||
'discontinued' => $this->translator->trans('m_status.discontinued'),
|
||||
],
|
||||
])
|
||||
->add('manufacturer_product_number', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.mpn'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('mass', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.mass'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
->add('tags', TextColumn::class, [
|
||||
'label' => $this->translator->trans('part.table.tags'),
|
||||
'visible' => false
|
||||
'visible' => false,
|
||||
])
|
||||
|
||||
->addOrderBy('name')
|
||||
->createAdapter(ORMAdapter::class, [
|
||||
'query' => function(QueryBuilder $builder) {
|
||||
'query' => function (QueryBuilder $builder) {
|
||||
$this->getQuery($builder);
|
||||
},
|
||||
'entity' => Part::class,
|
||||
|
@ -292,8 +284,8 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
function (QueryBuilder $builder) use ($options) {
|
||||
$this->buildCriteria($builder, $options);
|
||||
},
|
||||
new SearchCriteriaProvider()
|
||||
]
|
||||
new SearchCriteriaProvider(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue