Skip to content

Commit

Permalink
Merge branch '1.6' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Corepex committed Mar 12, 2024
2 parents ca67bfe + 2d8d815 commit 7f8ce45
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Data\ObjectMetadata;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;
use Pimcore\Model\Exception\NotFoundException;

class AdvancedManyToManyObjectRelation extends Base
{
Expand Down Expand Up @@ -58,6 +59,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
$item->setData($data);
}
$result[] = $item;
} else {
throw new NotFoundException(
sprintf('Element with id %s or fullpath %s not found',
$newValueItemValue['id'],
$newValueItemValue['fullpath']
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Data\ElementMetadata;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;
use Pimcore\Model\Exception\NotFoundException;

class AdvancedManyToManyRelation extends Base
{
Expand Down Expand Up @@ -57,6 +58,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
$item->setData($data);
}
$result[] = $item;
} else {
throw new NotFoundException(
sprintf('Element with id %s or fullpath %s not found',
$newValueItemValue['id'],
$newValueItemValue['fullpath']
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;
use Pimcore\Model\Exception\NotFoundException;

class ManyToManyObjectRelation extends Base
{
Expand Down Expand Up @@ -50,6 +51,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)

if ($element) {
$result[] = $element;
} else {
throw new NotFoundException(
sprintf('Element with id %s or fullpath %s not found',
$newValueItemValue['id'],
$newValueItemValue['fullpath']
)
);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/GraphQL/DataObjectInputProcessor/ManyToManyRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;
use Pimcore\Model\Exception\NotFoundException;

class ManyToManyRelation extends Base
{
Expand All @@ -45,6 +46,13 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)

if ($element) {
$result[] = $element;
} else {
throw new NotFoundException(
sprintf('Element with id %s or fullpath %s not found',
$newValueItemValue['id'],
$newValueItemValue['fullpath']
)
);
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/GraphQL/DataObjectInputProcessor/ManyToOneRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ElementIdentificationTrait;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;
use Pimcore\Model\Exception\NotFoundException;

class ManyToOneRelation extends Base
{
Expand All @@ -40,8 +41,18 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info):
$me = $this;
Service::setValue($object, $attribute, function ($container, $setter) use ($newValue) {
$element = null;

if (is_array($newValue)) {
$element = $this->getElementByTypeAndIdOrPath($newValue);

if (!$element) {
throw new NotFoundException(
sprintf('Element with id %s or fullpath %s not found',
$newValue['id'],
$newValue['fullpath']
)
);
}
}

return $container->$setter($element);
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL/Resolver/QueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ static function ($fullpath) use ($db) {
return $db->quote($tag);
}, $args['tags'])));

$conditionParts[] = "o_id IN (
$conditionParts[] = sprintf("%s IN (
SELECT cId FROM tags_assignment INNER JOIN tags ON tags.id = tags_assignment.tagid
WHERE
ctype = 'object' AND LOWER(tags.name) IN (" . $tags . '))';
ctype = 'object' AND LOWER(tags.name) IN (", Service::getVersionDependentDatabaseColumnName('o_id')) . $tags . '))';
}

// paging
Expand Down

0 comments on commit 7f8ce45

Please sign in to comment.