Make LabelGenerator services final.

This commit is contained in:
Jan Böhmer 2020-05-09 18:17:23 +02:00
parent 28187f1ef2
commit e925bec5b6
18 changed files with 48 additions and 48 deletions

View file

@ -56,7 +56,7 @@ use App\Form\AdminPages\MassCreationForm;
use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\Attachments\AttachmentSubmitHandler;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
use App\Services\LabelSystem\BarcodeExampleElementsGenerator; use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator;
use App\Services\LabelSystem\LabelGenerator; use App\Services\LabelSystem\LabelGenerator;
use App\Services\LogSystem\EventCommentHelper; use App\Services\LogSystem\EventCommentHelper;
use App\Services\LogSystem\HistoryHelper; use App\Services\LogSystem\HistoryHelper;

View file

@ -24,9 +24,9 @@ use App\Entity\LabelSystem\LabelOptions;
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator; use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
use Com\Tecnick\Barcode\Barcode; use Com\Tecnick\Barcode\Barcode;
class BarcodeGenerator final class BarcodeGenerator
{ {
protected $barcodeContentGenerator; private $barcodeContentGenerator;
public function __construct(BarcodeContentGenerator $barcodeContentGenerator) public function __construct(BarcodeContentGenerator $barcodeContentGenerator)
{ {

View file

@ -26,10 +26,10 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\EntityNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class BarcodeParser final class BarcodeParser
{ {
protected $urlGenerator; private $urlGenerator;
protected $em; private $em;
public function __construct(UrlGeneratorInterface $urlGenerator, EntityManagerInterface $entityManager) public function __construct(UrlGeneratorInterface $urlGenerator, EntityManagerInterface $entityManager)

View file

@ -30,9 +30,9 @@ use App\Entity\Parts\Supplier;
use App\Exceptions\EntityNotSupportedException; use App\Exceptions\EntityNotSupportedException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class BarcodeContentGenerator final class BarcodeContentGenerator
{ {
protected $urlGenerator; private $urlGenerator;
public const PREFIX_MAP = [ public const PREFIX_MAP = [
Part::class => 'P', Part::class => 'P',
@ -40,7 +40,7 @@ class BarcodeContentGenerator
Storelocation::class => 'S' Storelocation::class => 'S'
]; ];
protected const URL_MAP = [ private const URL_MAP = [
Part::class => 'part', Part::class => 'part',
PartLot::class => 'lot', PartLot::class => 'lot',
Storelocation::class => 'location', Storelocation::class => 'location',
@ -80,7 +80,7 @@ class BarcodeContentGenerator
return $prefix . $id; return $prefix . $id;
} }
protected function classToString(array $map, object $target): string private function classToString(array $map, object $target): string
{ {
$class = get_class($target); $class = get_class($target);
if (isset($map[$class])) { if (isset($map[$class])) {

View file

@ -18,7 +18,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace App\Services\LabelSystem; namespace App\Services\LabelSystem\Barcodes;
use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
@ -28,7 +28,7 @@ use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
class BarcodeExampleElementsGenerator final class BarcodeExampleElementsGenerator
{ {
public function getElement(string $type): object public function getElement(string $type): object
{ {
@ -44,7 +44,7 @@ class BarcodeExampleElementsGenerator
} }
} }
protected function getStorelocation(): Storelocation private function getStorelocation(): Storelocation
{ {
$storelocation = new Storelocation(); $storelocation = new Storelocation();
$storelocation->setName('Location 1'); $storelocation->setName('Location 1');
@ -59,7 +59,7 @@ class BarcodeExampleElementsGenerator
return $storelocation; return $storelocation;
} }
protected function getStructuralData(string $class): AbstractStructuralDBElement private function getStructuralData(string $class): AbstractStructuralDBElement
{ {
if (!is_a($class, AbstractStructuralDBElement::class, true)) { if (!is_a($class, AbstractStructuralDBElement::class, true)) {
throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement'); throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');

View file

@ -21,9 +21,9 @@
namespace App\Services\LabelSystem\Barcodes; namespace App\Services\LabelSystem\Barcodes;
class BarcodeNormalizer final class BarcodeNormalizer
{ {
protected const PREFIX_TYPE_MAP = [ private const PREFIX_TYPE_MAP = [
'L' => 'lot', 'L' => 'lot',
'P' => 'part', 'P' => 'part',
'S' => 'location', 'S' => 'location',

View file

@ -30,7 +30,7 @@ use App\Services\ElementTypeNameGenerator;
use Dompdf\Dompdf; use Dompdf\Dompdf;
use Twig\Environment; use Twig\Environment;
class LabelGenerator final class LabelGenerator
{ {
public const CLASS_SUPPORT_MAPPING = [ public const CLASS_SUPPORT_MAPPING = [
'part' => Part::class, 'part' => Part::class,
@ -40,7 +40,7 @@ class LabelGenerator
public const MM_TO_POINTS_FACTOR = 2.83465; public const MM_TO_POINTS_FACTOR = 2.83465;
protected $labelHTMLGenerator; private $labelHTMLGenerator;
public function __construct(LabelHTMLGenerator $labelHTMLGenerator) public function __construct(LabelHTMLGenerator $labelHTMLGenerator)
{ {

View file

@ -32,13 +32,13 @@ use Twig\Error\SyntaxError;
final class LabelHTMLGenerator final class LabelHTMLGenerator
{ {
protected $twig; private $twig;
protected $elementTypeNameGenerator; private $elementTypeNameGenerator;
protected $replacer; private $replacer;
protected $barcodeGenerator; private $barcodeGenerator;
protected $sandboxedTwigProvider; private $sandboxedTwigProvider;
protected $partdb_title; private $partdb_title;
protected $security; private $security;
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator, LabelTextReplacer $replacer, Environment $twig, public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator, LabelTextReplacer $replacer, Environment $twig,
BarcodeGenerator $barcodeGenerator, SandboxedTwigProvider $sandboxedTwigProvider, Security $security, string $partdb_title) BarcodeGenerator $barcodeGenerator, SandboxedTwigProvider $sandboxedTwigProvider, Security $security, string $partdb_title)

View file

@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface;
class LabelProfileDropdownHelper final class LabelProfileDropdownHelper
{ {
private $cache; private $cache;
private $entityManager; private $entityManager;

View file

@ -27,9 +27,9 @@ use App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface;
* It uses the PlaceholderProviders provided by PlaceholderProviderInterface classes. * It uses the PlaceholderProviders provided by PlaceholderProviderInterface classes.
* @package App\Services\LabelSystem * @package App\Services\LabelSystem
*/ */
class LabelTextReplacer final class LabelTextReplacer
{ {
protected $providers; private $providers;
public function __construct(iterable $providers) public function __construct(iterable $providers)
{ {

View file

@ -24,9 +24,9 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Services\ElementTypeNameGenerator; use App\Services\ElementTypeNameGenerator;
class AbstractDBElementProvider implements PlaceholderProviderInterface final class AbstractDBElementProvider implements PlaceholderProviderInterface
{ {
protected $elementTypeNameGenerator; private $elementTypeNameGenerator;
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator) public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator)
{ {

View file

@ -30,11 +30,11 @@ use Symfony\Component\Security\Core\Security;
* Provides Placeholders for infos about global infos like Installation name or datetimes. * Provides Placeholders for infos about global infos like Installation name or datetimes.
* @package App\Services\LabelSystem\PlaceholderProviders * @package App\Services\LabelSystem\PlaceholderProviders
*/ */
class GlobalProviders implements PlaceholderProviderInterface final class GlobalProviders implements PlaceholderProviderInterface
{ {
protected $partdb_title; private $partdb_title;
protected $security; private $security;
public function __construct(string $partdb_title, Security $security) public function __construct(string $partdb_title, Security $security)
{ {

View file

@ -23,7 +23,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\Contracts\NamedElementInterface; use App\Entity\Contracts\NamedElementInterface;
class NamedElementProvider implements PlaceholderProviderInterface final class NamedElementProvider implements PlaceholderProviderInterface
{ {
/** /**

View file

@ -27,10 +27,10 @@ use App\Services\LabelSystem\LabelTextReplacer;
use IntlDateFormatter; use IntlDateFormatter;
use Locale; use Locale;
class PartLotProvider implements PlaceholderProviderInterface final class PartLotProvider implements PlaceholderProviderInterface
{ {
protected $labelTextReplacer; private $labelTextReplacer;
protected $amountFormatter; private $amountFormatter;
public function __construct(LabelTextReplacer $labelTextReplacer, AmountFormatter $amountFormatter) public function __construct(LabelTextReplacer $labelTextReplacer, AmountFormatter $amountFormatter)
{ {

View file

@ -25,11 +25,11 @@ use App\Entity\Parts\Part;
use App\Services\SIFormatter; use App\Services\SIFormatter;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class PartProvider implements PlaceholderProviderInterface final class PartProvider implements PlaceholderProviderInterface
{ {
protected $siFormatter; private $siFormatter;
protected $translator; private $translator;
public function __construct(SIFormatter $SIFormatter, TranslatorInterface $translator) public function __construct(SIFormatter $SIFormatter, TranslatorInterface $translator)
{ {

View file

@ -24,7 +24,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Base\AbstractStructuralDBElement;
class StructuralDBElementProvider implements PlaceholderProviderInterface final class StructuralDBElementProvider implements PlaceholderProviderInterface
{ {
public function replace(string $placeholder, object $label_target, array $options = []): ?string public function replace(string $placeholder, object $label_target, array $options = []): ?string

View file

@ -24,7 +24,7 @@ use App\Entity\Contracts\TimeStampableInterface;
use IntlDateFormatter; use IntlDateFormatter;
use Locale; use Locale;
class TimestampableElementProvider implements PlaceholderProviderInterface final class TimestampableElementProvider implements PlaceholderProviderInterface
{ {
/** /**

View file

@ -48,10 +48,10 @@ use Twig\Extra\Intl\IntlExtension;
use Twig\Sandbox\SecurityPolicy; use Twig\Sandbox\SecurityPolicy;
use Twig\Sandbox\SecurityPolicyInterface; use Twig\Sandbox\SecurityPolicyInterface;
class SandboxedTwigProvider final class SandboxedTwigProvider
{ {
protected const ALLOWED_TAGS = ['apply', 'autoescape', 'do', 'for', 'if', 'set', 'verbatim', 'with']; private const ALLOWED_TAGS = ['apply', 'autoescape', 'do', 'for', 'if', 'set', 'verbatim', 'with'];
protected const ALLOWED_FILTERS = ['abs', 'batch', 'capitalize', 'column', 'country_name', private const ALLOWED_FILTERS = ['abs', 'batch', 'capitalize', 'column', 'country_name',
'currency_name', 'currency_symbol', 'date', 'date_modify', 'default', 'escape', 'filter', 'first', 'format', 'currency_name', 'currency_symbol', 'date', 'date_modify', 'default', 'escape', 'filter', 'first', 'format',
'format_currency', 'format_date', 'format_datetime', 'format_number', 'format_time', 'join', 'keys', 'format_currency', 'format_date', 'format_datetime', 'format_number', 'format_time', 'join', 'keys',
'language_name', 'last', 'length', 'locale_name', 'lower', 'map', 'merge', 'nl2br', 'raw', 'number_format', 'language_name', 'last', 'length', 'locale_name', 'lower', 'map', 'merge', 'nl2br', 'raw', 'number_format',
@ -60,9 +60,9 @@ class SandboxedTwigProvider
//Part-DB specific filters: //Part-DB specific filters:
'moneyFormat', 'siFormat', 'amountFormat']; 'moneyFormat', 'siFormat', 'amountFormat'];
protected const ALLOWED_FUNCTIONS = ['date', 'html_classes', 'max', 'min', 'random', 'range']; private const ALLOWED_FUNCTIONS = ['date', 'html_classes', 'max', 'min', 'random', 'range'];
protected const ALLOWED_METHODS = [ private const ALLOWED_METHODS = [
NamedElementInterface::class => ['getName'], NamedElementInterface::class => ['getName'],
AbstractDBElement::class => ['getID', '__toString'], AbstractDBElement::class => ['getID', '__toString'],
TimeStampableInterface::class => ['getLastModified', 'getAddedDate'], TimeStampableInterface::class => ['getLastModified', 'getAddedDate'],
@ -93,7 +93,7 @@ class SandboxedTwigProvider
'getDepartment', 'getEmail'] 'getDepartment', 'getEmail']
]; ];
protected const ALLOWED_PROPERTIES = []; private const ALLOWED_PROPERTIES = [];
private $appExtension; private $appExtension;