Fixed code style.

This commit is contained in:
Jan Böhmer 2020-01-04 20:24:09 +01:00
parent 1aed1d1d26
commit 9a7223a301
142 changed files with 534 additions and 716 deletions

View file

@ -21,7 +21,6 @@
namespace App\DataTables\Adapter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
@ -31,24 +30,25 @@ use Omines\DataTablesBundle\Column\AbstractColumn;
/**
* Override default ORM Adapter, to allow fetch joins (allow addSelect with ManyToOne Collections).
* This should improves performance for Part Tables.
* Based on: https://github.com/omines/datatables-bundle/blob/master/tests/Fixtures/AppBundle/DataTable/Adapter/CustomORMAdapter.php
* @package App\DataTables\Adapter
* Based on: https://github.com/omines/datatables-bundle/blob/master/tests/Fixtures/AppBundle/DataTable/Adapter/CustomORMAdapter.php.
*/
class CustomORMAdapter extends ORMAdapter
{
protected $hydrationMode;
public function configure(array $options)
{
parent::configure($options);
$this->hydrationMode = isset($options['hydrate']) ? $options['hydrate'] : Query::HYDRATE_OBJECT;
}
protected function prepareQuery(AdapterQuery $query)
{
parent::prepareQuery($query);
$query->setIdentifierPropertyPath(null);
}
/**
* @param AdapterQuery $query
* @return \Traversable
*/
protected function getResults(AdapterQuery $query): \Traversable
@ -78,4 +78,4 @@ class CustomORMAdapter extends ORMAdapter
yield $result;
}
}
}
}

View file

@ -21,7 +21,6 @@
namespace App\DataTables\Column;
use App\Services\MarkdownParser;
use Omines\DataTablesBundle\Column\AbstractColumn;
@ -38,10 +37,11 @@ class MarkdownColumn 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)
{
return $this->markdown->markForRendering($value, true);
}
}
}

View file

@ -21,21 +21,16 @@
namespace App\DataTables\Column;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part;
use App\Services\Attachments\AttachmentManager;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PartAttachmentsColumn extends AbstractColumn
{
protected $FAIconGenerator;
protected $urlGenerator;
protected $attachmentManager;
@ -51,6 +46,7 @@ class PartAttachmentsColumn 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)
@ -63,7 +59,7 @@ class PartAttachmentsColumn extends AbstractColumn
if (!$context instanceof Part) {
throw new \RuntimeException('$context must be a Part object!');
}
$tmp = "";
$tmp = '';
$attachments = $context->getAttachments()->filter(function (Attachment $attachment) {
return $attachment->getShowInTable() && $this->attachmentManager->isFileExisting($attachment);
});
@ -74,11 +70,11 @@ class PartAttachmentsColumn extends AbstractColumn
if (--$count < 0) {
break;
}
/** @var Attachment $attachment */
/* @var Attachment $attachment */
$tmp .= sprintf(
'<a href="%s" title="%s" class="attach-table-icon" target="_blank" rel="noopener" data-no-ajax>%s</a>',
$this->urlGenerator->viewURL($attachment),
htmlspecialchars($attachment->getName()) . ': ' . htmlspecialchars($attachment->getFilename()),
htmlspecialchars($attachment->getName()).': '.htmlspecialchars($attachment->getFilename()),
$this->FAIconGenerator->generateIconHTML(
// Sometimes the extension can not be determined, so ensure a generic icon is shown
$this->FAIconGenerator->fileExtensionToFAType($attachment->getExtension() ?? 'file'),
@ -95,4 +91,4 @@ class PartAttachmentsColumn extends AbstractColumn
{
parent::configureOptions($resolver);
}
}
}

View file

@ -21,13 +21,11 @@
namespace App\DataTables\Column;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class TagsColumn extends AbstractColumn
{
protected $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
@ -39,6 +37,7 @@ class TagsColumn 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)
@ -46,6 +45,7 @@ class TagsColumn extends AbstractColumn
if (empty($value)) {
return [];
}
return explode(',', $value);
}
@ -67,4 +67,4 @@ class TagsColumn extends AbstractColumn
return $html;
}
}
}

View file

@ -27,7 +27,6 @@ use App\DataTables\Column\LocaleDateTimeColumn;
use App\DataTables\Column\MarkdownColumn;
use App\DataTables\Column\PartAttachmentsColumn;
use App\DataTables\Column\TagsColumn;
use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
@ -38,19 +37,15 @@ use App\Services\AmountFormatter;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\Attachments\PartPreviewGenerator;
use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator;
use App\Services\MarkdownParser;
use App\Services\Trees\NodesListBuilder;
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\MapColumn;
use Omines\DataTablesBundle\Column\TextColumn;
use Omines\DataTablesBundle\DataTable;
use Omines\DataTablesBundle\DataTableTypeInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function foo\func;
class PartsDataTable implements DataTableTypeInterface
{