-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from pimcore/image_rel
Query assets by language not working
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/GraphQL/DataObjectQueryFieldConfigGenerator/Helper/Image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\DataHubBundle\GraphQL\DataObjectQueryFieldConfigGenerator\Helper; | ||
|
||
use GraphQL\Type\Definition\ResolveInfo; | ||
use Pimcore\Bundle\DataHubBundle\GraphQL\ElementDescriptor; | ||
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait; | ||
use Pimcore\Bundle\DataHubBundle\WorkspaceHelper; | ||
use Pimcore\Model\Asset; | ||
|
||
class Image | ||
{ | ||
use ServiceTrait; | ||
|
||
/** | ||
* @var | ||
*/ | ||
public $fieldDefinition; | ||
|
||
/** | ||
* @var | ||
*/ | ||
public $class; | ||
|
||
/** | ||
* @var | ||
*/ | ||
public $attribute; | ||
|
||
/** | ||
* Href constructor. | ||
* | ||
* @param \Pimcore\Bundle\DataHubBundle\GraphQL\Service $graphQlService | ||
* @param $attribute | ||
* @param $fieldDefinition | ||
* @param $class | ||
*/ | ||
public function __construct(\Pimcore\Bundle\DataHubBundle\GraphQL\Service $graphQlService, $attribute, $fieldDefinition, $class) | ||
{ | ||
$this->attribute = $attribute; | ||
$this->fieldDefinition = $fieldDefinition; | ||
$this->class = $class; | ||
|
||
$this->setGraphQLService($graphQlService); | ||
} | ||
|
||
/** | ||
* @param null $value | ||
* @param array $args | ||
* @param array $context | ||
* @param ResolveInfo|null $resolveInfo | ||
* | ||
* @return array|null | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function resolve($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null) | ||
{ | ||
$relation = \Pimcore\Bundle\DataHubBundle\GraphQL\Service::resolveValue($value, $this->fieldDefinition, $this->attribute, $args); | ||
|
||
if ($relation instanceof Asset) { | ||
if (!WorkspaceHelper::checkPermission($relation, 'read')) { | ||
return null; | ||
} | ||
|
||
$data = new ElementDescriptor($relation); | ||
$this->getGraphQlService()->extractData($data, $relation, $args, $context, $resolveInfo); | ||
|
||
return $data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters