Skip to content

Commit

Permalink
Addressed some qodana warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo-ele committed Jan 30, 2024
1 parent 91db3b3 commit 1a3ab14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Resolver/Location/FindParentStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Pimcore\Bundle\DataImporterBundle\Exception\InvalidInputException;
use Pimcore\Bundle\DataImporterBundle\Tool\DataObjectLoader;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\AbstractObject;
use Pimcore\Model\DataObject\ClassDefinition;
use Pimcore\Model\Element\ElementInterface;

Expand Down Expand Up @@ -134,7 +135,7 @@ public function updateParent(ElementInterface $element, array $inputData): Eleme
}

if ($newParent) {
if ($newParent->getType() === DataObject::OBJECT_TYPE_VARIANT) {
if ($newParent->getType() === AbstractObject::OBJECT_TYPE_VARIANT) {
throw new InvalidInputException(
'The elements desired parent is a variant which cannot have any child elements'
);
Expand All @@ -148,8 +149,7 @@ public function updateParent(ElementInterface $element, array $inputData): Eleme
&& $element->getClass()->getAllowVariants()

Check notice on line 149 in src/Resolver/Location/FindParentStrategy.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unhandled exception

Unhandled exceptions
&& !$element->hasChildren()

Check notice on line 150 in src/Resolver/Location/FindParentStrategy.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Non-optimal if conditions

\[EA\] This condition execution costs less than the previous one.
) {
/** @var DataObject\Concrete $element */
$element->setType(DataObject::OBJECT_TYPE_VARIANT);
$element->setType(AbstractObject::OBJECT_TYPE_VARIANT);
}

return $element->setParent($newParent);
Expand Down
4 changes: 2 additions & 2 deletions src/Resolver/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Pimcore\Bundle\DataImporterBundle\Resolver\Load\LoadStrategyInterface;
use Pimcore\Bundle\DataImporterBundle\Resolver\Location\LocationStrategyInterface;
use Pimcore\Bundle\DataImporterBundle\Resolver\Publish\PublishStrategyInterface;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\AbstractObject;
use Pimcore\Model\Element\ElementInterface;

class Resolver
Expand Down Expand Up @@ -155,7 +155,7 @@ public function loadOrCreateAndPrepareElement(array $inputData, bool $createNew
$this->getLocationUpdateStrategy()->updateParent($element, $inputData);

// The parent of a variant cannot be changed anymore.
if ($oldParentId !== $element->getParentId() && $element->getType() === DataObject::OBJECT_TYPE_VARIANT) {
if ($oldParentId !== $element->getParentId() && $element->getType() === AbstractObject::OBJECT_TYPE_VARIANT) {

Check warning on line 158 in src/Resolver/Resolver.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Line is longer than allowed by code style

Line is longer than allowed by code style (\> 120 columns)

Check warning on line 158 in src/Resolver/Resolver.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Line is longer than allowed by code style

Line is longer than allowed by code style (\> 120 columns)
throw new InvalidInputException(

Check notice on line 159 in src/Resolver/Resolver.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Unhandled exception

Unhandled exceptions
"Element with id `{$element->getId()}` is a variant and cannot change its parent anymore"
);
Expand Down

0 comments on commit 1a3ab14

Please sign in to comment.