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\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;

View file

@ -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)
{

View file

@ -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)

View file

@ -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])) {

View file

@ -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');

View file

@ -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',

View file

@ -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)
{

View file

@ -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)

View file

@ -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;

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -23,7 +23,7 @@ namespace App\Services\LabelSystem\PlaceholderProviders;
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 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)
{

View file

@ -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)
{

View file

@ -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

View file

@ -24,7 +24,7 @@ use App\Entity\Contracts\TimeStampableInterface;
use IntlDateFormatter;
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\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;