Applied rector with PHP8.1 migration rules

This commit is contained in:
Jan Böhmer 2023-06-11 14:15:46 +02:00
parent dc6a67c2f0
commit 7ee01d9a05
303 changed files with 1228 additions and 3465 deletions

View file

@ -62,20 +62,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
#[Route(path: '/label')]
class LabelController extends AbstractController
{
protected LabelGenerator $labelGenerator;
protected EntityManagerInterface $em;
protected ElementTypeNameGenerator $elementTypeNameGenerator;
protected RangeParser $rangeParser;
protected TranslatorInterface $translator;
public function __construct(LabelGenerator $labelGenerator, EntityManagerInterface $em, ElementTypeNameGenerator $elementTypeNameGenerator,
RangeParser $rangeParser, TranslatorInterface $translator)
public function __construct(protected LabelGenerator $labelGenerator, protected EntityManagerInterface $em, protected ElementTypeNameGenerator $elementTypeNameGenerator, protected RangeParser $rangeParser, protected TranslatorInterface $translator)
{
$this->labelGenerator = $labelGenerator;
$this->em = $em;
$this->elementTypeNameGenerator = $elementTypeNameGenerator;
$this->rangeParser = $rangeParser;
$this->translator = $translator;
}
#[Route(path: '/dialog', name: 'label_dialog')]
@ -85,15 +73,11 @@ class LabelController extends AbstractController
$this->denyAccessUnlessGranted('@labels.create_labels');
//If we inherit a LabelProfile, the user need to have access to it...
if (null !== $profile) {
if ($profile instanceof \App\Entity\LabelSystem\LabelProfile) {
$this->denyAccessUnlessGranted('read', $profile);
}
if ($profile) {
$label_options = $profile->getOptions();
} else {
$label_options = new LabelOptions();
}
$label_options = $profile instanceof \App\Entity\LabelSystem\LabelProfile ? $profile->getOptions() : new LabelOptions();
//We have to disable the options, if twig mode is selected and user is not allowed to use it.
$disable_options = 'twig' === $label_options->getLinesMode() && !$this->isGranted('@labels.use_twig');
@ -107,7 +91,7 @@ class LabelController extends AbstractController
$target_id = $request->query->get('target_id', null);
$generate = $request->query->getBoolean('generate', false);
if (null === $profile && is_string($target_type)) {
if (!$profile instanceof \App\Entity\LabelSystem\LabelProfile && is_string($target_type)) {
$label_options->setSupportedElement($target_type);
}
if (is_string($target_id)) {
@ -124,10 +108,10 @@ class LabelController extends AbstractController
$filename = 'invalid.pdf';
//Generate PDF either when the form is submitted and valid, or the form was not submit yet, and generate is set
if (($form->isSubmitted() && $form->isValid()) || ($generate && !$form->isSubmitted() && null !== $profile)) {
if (($form->isSubmitted() && $form->isValid()) || ($generate && !$form->isSubmitted() && $profile instanceof \App\Entity\LabelSystem\LabelProfile)) {
$target_id = (string) $form->get('target_id')->getData();
$targets = $this->findObjects($form_options->getSupportedElement(), $target_id);
if (!empty($targets)) {
if ($targets !== []) {
try {
$pdf_data = $this->labelGenerator->generateLabel($form_options, $targets);
$filename = $this->getLabelName($targets[0], $profile);