mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Make LabelGenerator services final.
This commit is contained in:
parent
28187f1ef2
commit
e925bec5b6
18 changed files with 48 additions and 48 deletions
|
@ -56,7 +56,7 @@ use App\Form\AdminPages\MassCreationForm;
|
|||
use App\Services\Attachments\AttachmentSubmitHandler;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
use App\Services\LabelSystem\BarcodeExampleElementsGenerator;
|
||||
use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator;
|
||||
use App\Services\LabelSystem\LabelGenerator;
|
||||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\LogSystem\HistoryHelper;
|
||||
|
|
|
@ -24,9 +24,9 @@ use App\Entity\LabelSystem\LabelOptions;
|
|||
use App\Services\LabelSystem\Barcodes\BarcodeContentGenerator;
|
||||
use Com\Tecnick\Barcode\Barcode;
|
||||
|
||||
class BarcodeGenerator
|
||||
final class BarcodeGenerator
|
||||
{
|
||||
protected $barcodeContentGenerator;
|
||||
private $barcodeContentGenerator;
|
||||
|
||||
public function __construct(BarcodeContentGenerator $barcodeContentGenerator)
|
||||
{
|
||||
|
|
|
@ -26,10 +26,10 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Doctrine\ORM\EntityNotFoundException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class BarcodeParser
|
||||
final class BarcodeParser
|
||||
{
|
||||
protected $urlGenerator;
|
||||
protected $em;
|
||||
private $urlGenerator;
|
||||
private $em;
|
||||
|
||||
|
||||
public function __construct(UrlGeneratorInterface $urlGenerator, EntityManagerInterface $entityManager)
|
||||
|
|
|
@ -30,9 +30,9 @@ use App\Entity\Parts\Supplier;
|
|||
use App\Exceptions\EntityNotSupportedException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class BarcodeContentGenerator
|
||||
final class BarcodeContentGenerator
|
||||
{
|
||||
protected $urlGenerator;
|
||||
private $urlGenerator;
|
||||
|
||||
public const PREFIX_MAP = [
|
||||
Part::class => 'P',
|
||||
|
@ -40,7 +40,7 @@ class BarcodeContentGenerator
|
|||
Storelocation::class => 'S'
|
||||
];
|
||||
|
||||
protected const URL_MAP = [
|
||||
private const URL_MAP = [
|
||||
Part::class => 'part',
|
||||
PartLot::class => 'lot',
|
||||
Storelocation::class => 'location',
|
||||
|
@ -80,7 +80,7 @@ class BarcodeContentGenerator
|
|||
return $prefix . $id;
|
||||
}
|
||||
|
||||
protected function classToString(array $map, object $target): string
|
||||
private function classToString(array $map, object $target): string
|
||||
{
|
||||
$class = get_class($target);
|
||||
if (isset($map[$class])) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* 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\Parts\Category;
|
||||
|
@ -28,7 +28,7 @@ use App\Entity\Parts\Part;
|
|||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
|
||||
class BarcodeExampleElementsGenerator
|
||||
final class BarcodeExampleElementsGenerator
|
||||
{
|
||||
public function getElement(string $type): object
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ class BarcodeExampleElementsGenerator
|
|||
}
|
||||
}
|
||||
|
||||
protected function getStorelocation(): Storelocation
|
||||
private function getStorelocation(): Storelocation
|
||||
{
|
||||
$storelocation = new Storelocation();
|
||||
$storelocation->setName('Location 1');
|
||||
|
@ -59,7 +59,7 @@ class BarcodeExampleElementsGenerator
|
|||
return $storelocation;
|
||||
}
|
||||
|
||||
protected function getStructuralData(string $class): AbstractStructuralDBElement
|
||||
private function getStructuralData(string $class): AbstractStructuralDBElement
|
||||
{
|
||||
if (!is_a($class, AbstractStructuralDBElement::class, true)) {
|
||||
throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
|
|
@ -21,9 +21,9 @@
|
|||
namespace App\Services\LabelSystem\Barcodes;
|
||||
|
||||
|
||||
class BarcodeNormalizer
|
||||
final class BarcodeNormalizer
|
||||
{
|
||||
protected const PREFIX_TYPE_MAP = [
|
||||
private const PREFIX_TYPE_MAP = [
|
||||
'L' => 'lot',
|
||||
'P' => 'part',
|
||||
'S' => 'location',
|
||||
|
|
|
@ -30,7 +30,7 @@ use App\Services\ElementTypeNameGenerator;
|
|||
use Dompdf\Dompdf;
|
||||
use Twig\Environment;
|
||||
|
||||
class LabelGenerator
|
||||
final class LabelGenerator
|
||||
{
|
||||
public const CLASS_SUPPORT_MAPPING = [
|
||||
'part' => Part::class,
|
||||
|
@ -40,7 +40,7 @@ class LabelGenerator
|
|||
|
||||
public const MM_TO_POINTS_FACTOR = 2.83465;
|
||||
|
||||
protected $labelHTMLGenerator;
|
||||
private $labelHTMLGenerator;
|
||||
|
||||
public function __construct(LabelHTMLGenerator $labelHTMLGenerator)
|
||||
{
|
||||
|
|
|
@ -32,13 +32,13 @@ use Twig\Error\SyntaxError;
|
|||
|
||||
final class LabelHTMLGenerator
|
||||
{
|
||||
protected $twig;
|
||||
protected $elementTypeNameGenerator;
|
||||
protected $replacer;
|
||||
protected $barcodeGenerator;
|
||||
protected $sandboxedTwigProvider;
|
||||
protected $partdb_title;
|
||||
protected $security;
|
||||
private $twig;
|
||||
private $elementTypeNameGenerator;
|
||||
private $replacer;
|
||||
private $barcodeGenerator;
|
||||
private $sandboxedTwigProvider;
|
||||
private $partdb_title;
|
||||
private $security;
|
||||
|
||||
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator, LabelTextReplacer $replacer, Environment $twig,
|
||||
BarcodeGenerator $barcodeGenerator, SandboxedTwigProvider $sandboxedTwigProvider, Security $security, string $partdb_title)
|
||||
|
|
|
@ -28,7 +28,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||
|
||||
class LabelProfileDropdownHelper
|
||||
final class LabelProfileDropdownHelper
|
||||
{
|
||||
private $cache;
|
||||
private $entityManager;
|
||||
|
|
|
@ -27,9 +27,9 @@ use App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface;
|
|||
* It uses the PlaceholderProviders provided by PlaceholderProviderInterface classes.
|
||||
* @package App\Services\LabelSystem
|
||||
*/
|
||||
class LabelTextReplacer
|
||||
final class LabelTextReplacer
|
||||
{
|
||||
protected $providers;
|
||||
private $providers;
|
||||
|
||||
public function __construct(iterable $providers)
|
||||
{
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
|
|||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
|
||||
class AbstractDBElementProvider implements PlaceholderProviderInterface
|
||||
final class AbstractDBElementProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
protected $elementTypeNameGenerator;
|
||||
private $elementTypeNameGenerator;
|
||||
|
||||
public function __construct(ElementTypeNameGenerator $elementTypeNameGenerator)
|
||||
{
|
||||
|
|
|
@ -30,11 +30,11 @@ use Symfony\Component\Security\Core\Security;
|
|||
* Provides Placeholders for infos about global infos like Installation name or datetimes.
|
||||
* @package App\Services\LabelSystem\PlaceholderProviders
|
||||
*/
|
||||
class GlobalProviders implements PlaceholderProviderInterface
|
||||
final class GlobalProviders implements PlaceholderProviderInterface
|
||||
{
|
||||
|
||||
protected $partdb_title;
|
||||
protected $security;
|
||||
private $partdb_title;
|
||||
private $security;
|
||||
|
||||
public function __construct(string $partdb_title, Security $security)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
|
|||
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
|
||||
class NamedElementProvider implements PlaceholderProviderInterface
|
||||
final class NamedElementProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,10 +27,10 @@ use App\Services\LabelSystem\LabelTextReplacer;
|
|||
use IntlDateFormatter;
|
||||
use Locale;
|
||||
|
||||
class PartLotProvider implements PlaceholderProviderInterface
|
||||
final class PartLotProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
protected $labelTextReplacer;
|
||||
protected $amountFormatter;
|
||||
private $labelTextReplacer;
|
||||
private $amountFormatter;
|
||||
|
||||
public function __construct(LabelTextReplacer $labelTextReplacer, AmountFormatter $amountFormatter)
|
||||
{
|
||||
|
|
|
@ -25,11 +25,11 @@ use App\Entity\Parts\Part;
|
|||
use App\Services\SIFormatter;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class PartProvider implements PlaceholderProviderInterface
|
||||
final class PartProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
|
||||
protected $siFormatter;
|
||||
protected $translator;
|
||||
private $siFormatter;
|
||||
private $translator;
|
||||
|
||||
public function __construct(SIFormatter $SIFormatter, TranslatorInterface $translator)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
|
|||
use App\Entity\Base\AbstractDBElement;
|
||||
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
|
||||
|
|
|
@ -24,7 +24,7 @@ use App\Entity\Contracts\TimeStampableInterface;
|
|||
use IntlDateFormatter;
|
||||
use Locale;
|
||||
|
||||
class TimestampableElementProvider implements PlaceholderProviderInterface
|
||||
final class TimestampableElementProvider implements PlaceholderProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,10 +48,10 @@ use Twig\Extra\Intl\IntlExtension;
|
|||
use Twig\Sandbox\SecurityPolicy;
|
||||
use Twig\Sandbox\SecurityPolicyInterface;
|
||||
|
||||
class SandboxedTwigProvider
|
||||
final class SandboxedTwigProvider
|
||||
{
|
||||
protected const ALLOWED_TAGS = ['apply', 'autoescape', 'do', 'for', 'if', 'set', 'verbatim', 'with'];
|
||||
protected const ALLOWED_FILTERS = ['abs', 'batch', 'capitalize', 'column', 'country_name',
|
||||
private const ALLOWED_TAGS = ['apply', 'autoescape', 'do', 'for', 'if', 'set', 'verbatim', 'with'];
|
||||
private const ALLOWED_FILTERS = ['abs', 'batch', 'capitalize', 'column', 'country_name',
|
||||
'currency_name', 'currency_symbol', 'date', 'date_modify', 'default', 'escape', 'filter', 'first', 'format',
|
||||
'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',
|
||||
|
@ -60,9 +60,9 @@ class SandboxedTwigProvider
|
|||
//Part-DB specific filters:
|
||||
'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'],
|
||||
AbstractDBElement::class => ['getID', '__toString'],
|
||||
TimeStampableInterface::class => ['getLastModified', 'getAddedDate'],
|
||||
|
@ -93,7 +93,7 @@ class SandboxedTwigProvider
|
|||
'getDepartment', 'getEmail']
|
||||
|
||||
];
|
||||
protected const ALLOWED_PROPERTIES = [];
|
||||
private const ALLOWED_PROPERTIES = [];
|
||||
|
||||
private $appExtension;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue